]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
conncache: use the closure handle when disconnecting surplus connections
authorDaniel Stenberg <daniel@haxx.se>
Sat, 25 Nov 2023 23:10:17 +0000 (00:10 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 26 Nov 2023 16:49:15 +0000 (17:49 +0100)
Use the closure handle for disconnecting connection cache entries so
that anything that happens during the disconnect is not stored and
associated with the 'data' handle which already just finished a transfer
and it is important that details from the unrelated disconnect does not
taint meta-data in the data handle.

Like storing the response code.

This also adjust test 1506. Unfortunately it also removes a key part of
the test that verifies that a connection is closed since when this
output vanishes (because the closure handle is used), we don't know
exactly that the connection actually gets closed in this test...

Reported-by: ohyeaah on github
Fixes #12367
Closes #12405

lib/conncache.c
tests/data/test1506

index a831a94ce10ba303709069eea9cbb19c9728e09c..66f18ecb850e5d3377524d43c4aa2a478b4d5ca9 100644 (file)
@@ -389,8 +389,16 @@ bool Curl_conncache_return_conn(struct Curl_easy *data,
 
     conn_candidate = Curl_conncache_extract_oldest(data);
     if(conn_candidate) {
-      /* the winner gets the honour of being disconnected */
-      Curl_disconnect(data, conn_candidate, /* dead_connection */ FALSE);
+      /* Use the closure handle for this disconnect so that anything that
+         happens during the disconnect is not stored and associated with the
+         'data' handle which already just finished a transfer and it is
+         important that details from this (unrelated) disconnect does not
+         taint meta-data in the data handle. */
+      struct conncache *connc = data->state.conn_cache;
+      connc->closure_handle->state.buffer = data->state.buffer;
+      connc->closure_handle->set.buffer_size = data->set.buffer_size;
+      Curl_disconnect(connc->closure_handle, conn_candidate,
+                      /* dead_connection */ FALSE);
     }
   }
 
index 9eb38cf6d115d409946745b096fb8873c1524827..0a62c0c2a6424ce3729822f781e8410fdfbf63c1 100644 (file)
@@ -86,7 +86,6 @@ Accept: */*
 * Connection #0 to host server1.example.com left intact
 * Connection #1 to host server2.example.com left intact
 * Connection #2 to host server3.example.com left intact
-* Closing connection
 * Connection #3 to host server4.example.com left intact
 </file>
 <stripfile>