From 95a865b462195d9d847f7f2676f0c789179e2073 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 4 Sep 2023 14:14:32 +0200 Subject: [PATCH] transfer: also stop the sending on closed connection 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 Conflict: context adapt Reference: https://github.com/curl/curl/commit/95a865b462195d9d847f7f2676f0c789179e2073 --- lib/transfer.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/transfer.c b/lib/transfer.c index fdfa6b1..c8db8d9 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -633,7 +633,7 @@ 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 http2 stream is closed or the server closed the connection and we bail out from this! */ #ifdef USE_NGHTTP2 @@ -642,8 +642,9 @@ static CURLcode readwrite_data(struct Curl_easy *data, else #endif 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 -- 2.33.0