From 88c5c63ffc3312a8c8471b48a44ec5f50420f2e3 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 19 Jun 2013 23:54:28 +0200 Subject: multi_socket: react on socket close immediately As a remedy to the problem when a socket gets closed and a new one is opened with the same file descriptor number and as a result multi.c:singlesocket() doesn't detect the difference, the new function Curl_multi_closed() gets told when a socket is closed so that it can be removed from the socket hash. When the old one has been removed, a new socket should be detected fine by the singlesocket() on next invoke. Bug: http://curl.haxx.se/bug/view.cgi?id=1248 Reported-by: Erik Johansson --- lib/connect.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lib/connect.c') diff --git a/lib/connect.c b/lib/connect.c index 2d5b641af..be8c0e45a 100644 --- a/lib/connect.c +++ b/lib/connect.c @@ -1239,7 +1239,7 @@ curl_socket_t Curl_getconnectinfo(struct SessionHandle *data, * 'conn' can be NULL, beware! */ int Curl_closesocket(struct connectdata *conn, - curl_socket_t sock) + curl_socket_t sock) { if(conn && conn->fclosesocket) { if((sock == conn->sock[SECONDARYSOCKET]) && @@ -1251,7 +1251,13 @@ int Curl_closesocket(struct connectdata *conn, else return conn->fclosesocket(conn->closesocket_client, sock); } - return sclose(sock); + sclose(sock); + + if(conn) + /* tell the multi-socket code about this */ + Curl_multi_closed(conn, sock); + + return 0; } /* -- cgit v1.2.3