pause: return early for calls that don't change pause state

Reviewed-by: Patrick Monnerat
Ref: #4833
Closes #5026
diff --git a/lib/easy.c b/lib/easy.c
index 4546210..2446557 100644
--- a/lib/easy.c
+++ b/lib/easy.c
@@ -975,6 +975,7 @@
 {
   struct SingleRequest *k = &data->req;
   CURLcode result = CURLE_OK;
+  int oldstate = k->keepon & (KEEP_RECV_PAUSE| KEEP_SEND_PAUSE);
 
   /* first switch off both pause bits */
   int newstate = k->keepon &~ (KEEP_RECV_PAUSE| KEEP_SEND_PAUSE);
@@ -983,6 +984,12 @@
   newstate |= ((action & CURLPAUSE_RECV)?KEEP_RECV_PAUSE:0) |
     ((action & CURLPAUSE_SEND)?KEEP_SEND_PAUSE:0);
 
+  if((newstate & (KEEP_RECV_PAUSE| KEEP_SEND_PAUSE)) == oldstate) {
+    /* Not changing any pause state, return */
+    DEBUGF(infof(data, "pause: no change, early return\n"));
+    return CURLE_OK;
+  }
+
   /* put it back in the keepon */
   k->keepon = newstate;