summaryrefslogtreecommitdiff
path: root/lib/multi.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2022-08-22 10:56:42 +0200
committerDaniel Stenberg <daniel@haxx.se>2022-08-23 13:44:11 +0200
commit31a41d45b70310e7bce8166e16cb8039272b8335 (patch)
tree2d1a830ac438c6de5c9fd3c6ee0e683418c8c469 /lib/multi.c
parentfdbcd3948840272063b424e62e5e0882ebf94d35 (diff)
downloadcurl-31a41d45b70310e7bce8166e16cb8039272b8335.tar.gz
multi: have curl_multi_remove_handle close CONNECT_ONLY transfer
αΊ‚hen it has been used in the multi interface, it is otherwise left in the connection cache, can't be reused and nothing will close them since the easy handle loses the association with the multi handle and thus the connection cache - until the multi handle is closed or it gets pruned because the cache is full. Reported-by: Dominik Thalhammer Fixes #9335 Closes #9342
Diffstat (limited to 'lib/multi.c')
-rw-r--r--lib/multi.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/multi.c b/lib/multi.c
index a5217ee2c..2527de3a6 100644
--- a/lib/multi.c
+++ b/lib/multi.c
@@ -828,6 +828,24 @@ CURLMcode curl_multi_remove_handle(struct Curl_multi *multi,
/* Remove the association between the connection and the handle */
Curl_detach_connection(data);
+ if(data->set.connect_only && !data->multi_easy) {
+ /* This removes a handle that was part the multi inteface that used
+ CONNECT_ONLY, that connection is now left alive but since this handle
+ has bits.close set nothing can use that transfer anymore and it is
+ forbidden from reuse. And this easy handle cannot find the connection
+ anymore once removed from the multi handle
+
+ Better close the connection here, at once.
+ */
+ struct connectdata *c;
+ curl_socket_t s;
+ s = Curl_getconnectinfo(data, &c);
+ if((s != CURL_SOCKET_BAD) && c) {
+ Curl_conncache_remove_conn(data, c, TRUE);
+ Curl_disconnect(data, c, TRUE);
+ }
+ }
+
if(data->state.lastconnect_id != -1) {
/* Mark any connect-only connection for closure */
Curl_conncache_foreach(data, data->state.conn_cache,