]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
pause: return early for calls that don't change pause state
authorDaniel Stenberg <daniel@haxx.se>
Tue, 3 Mar 2020 07:10:09 +0000 (08:10 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 6 Mar 2020 09:25:40 +0000 (10:25 +0100)
Reviewed-by: Patrick Monnerat
Ref: #4833
Closes #5026

lib/easy.c

index 454621076ab2bc015f53177c6b361d0f59f24c36..2446557f4d215080c2b8996a524a2e8342b8000c 100644 (file)
@@ -975,6 +975,7 @@ CURLcode curl_easy_pause(struct Curl_easy *data, int action)
 {
   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 @@ CURLcode curl_easy_pause(struct Curl_easy *data, int action)
   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;