diff options
author | Romain Fliedel <rfliedel@freebox.fr> | 2018-11-05 11:01:19 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2018-11-20 19:58:45 +0100 |
commit | 6765e6d9e6a32bb4fc666d744cb57e2d55d4e13b (patch) | |
tree | 4cef970f234a13fc1a75d28c93bda49a33226e74 /lib/connect.c | |
parent | 47ccb2d204eb9c1d3e98b3febd616af42d82c184 (diff) | |
download | curl-6765e6d9e6a32bb4fc666d744cb57e2d55d4e13b.tar.gz |
ares: remove fd from multi fd set when ares is about to close the fd
When using c-ares for asyn dns, the dns socket fd was silently closed
by c-ares without curl being aware. curl would then 'realize' the fd
has been removed at next call of Curl_resolver_getsock, and only then
notify the CURLMOPT_SOCKETFUNCTION to remove fd from its poll set with
CURL_POLL_REMOVE. At this point the fd is already closed.
By using ares socket state callback (ARES_OPT_SOCK_STATE_CB), this
patch allows curl to be notified that the fd is not longer needed
for neither for write nor read. At this point by calling
Curl_multi_closed we are able to notify multi with CURL_POLL_REMOVE
before the fd is actually closed by ares.
In asyn-ares.c Curl_resolver_duphandle we can't use ares_dup anymore
since it does not allow passing a different sock_state_cb_data
Closes #3238
Diffstat (limited to 'lib/connect.c')
-rw-r--r-- | lib/connect.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/connect.c b/lib/connect.c index 41f220268..18645b9b7 100644 --- a/lib/connect.c +++ b/lib/connect.c @@ -1314,7 +1314,7 @@ int Curl_closesocket(struct connectdata *conn, conn->sock_accepted[SECONDARYSOCKET] = FALSE; else { int rc; - Curl_multi_closed(conn, sock); + Curl_multi_closed(conn->data, sock); Curl_set_in_callback(conn->data, true); rc = conn->fclosesocket(conn->closesocket_client, sock); Curl_set_in_callback(conn->data, false); @@ -1324,7 +1324,7 @@ int Curl_closesocket(struct connectdata *conn, if(conn) /* tell the multi-socket code about this */ - Curl_multi_closed(conn, sock); + Curl_multi_closed(conn->data, sock); sclose(sock); |