]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
transfer: also stop the sending on closed connection
authorDaniel Stenberg <daniel@haxx.se>
Mon, 4 Sep 2023 12:14:32 +0000 (14:14 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 4 Sep 2023 17:51:59 +0000 (19:51 +0200)
Previously this cleared the receiving bit only but in some cases it is
also still sending (like a request-body) when disconnected and neither
direction can continue then.

Fixes #11769
Reported-by: Oleg Jukovec
Closes #11795

lib/transfer.c

index fb0a6a45d916c6792d7100f8a570d4f82e796eec..d0602b8753bc097b8e71820201fabfedcb7ceda7 100644 (file)
@@ -492,15 +492,16 @@ static CURLcode readwrite_data(struct Curl_easy *data,
     if(0 < nread || is_empty_data) {
       buf[nread] = 0;
     }
-    else {
+    if(!nread) {
       /* if we receive 0 or less here, either the data transfer is done or the
          server closed the connection and we bail out from this! */
       if(data_eof_handled)
         DEBUGF(infof(data, "nread == 0, stream closed, bailing"));
       else
         DEBUGF(infof(data, "nread <= 0, server closed connection, bailing"));
-      k->keepon &= ~KEEP_RECV;
-      break;
+      k->keepon = 0; /* stop sending as well */
+      if(!is_empty_data)
+        break;
     }
 
     /* Default buffer to use when we write the buffer, it may be changed