summaryrefslogtreecommitdiff
path: root/lib/multi.c
diff options
context:
space:
mode:
authorRomain Fliedel <rfliedel@freebox.fr>2018-11-05 11:01:19 +0100
committerDaniel Stenberg <daniel@haxx.se>2018-11-20 19:58:45 +0100
commit6765e6d9e6a32bb4fc666d744cb57e2d55d4e13b (patch)
tree4cef970f234a13fc1a75d28c93bda49a33226e74 /lib/multi.c
parent47ccb2d204eb9c1d3e98b3febd616af42d82c184 (diff)
downloadcurl-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/multi.c')
-rw-r--r--lib/multi.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/multi.c b/lib/multi.c
index 0db2a9730..fbd389716 100644
--- a/lib/multi.c
+++ b/lib/multi.c
@@ -2466,11 +2466,11 @@ void Curl_updatesocket(struct Curl_easy *data)
* socket again and it gets the same file descriptor number.
*/
-void Curl_multi_closed(struct connectdata *conn, curl_socket_t s)
+void Curl_multi_closed(struct Curl_easy *data, curl_socket_t s)
{
- if(conn->data) {
+ if(data) {
/* if there's still an easy handle associated with this connection */
- struct Curl_multi *multi = conn->data->multi;
+ struct Curl_multi *multi = data->multi;
if(multi) {
/* this is set if this connection is part of a handle that is added to
a multi handle, and only then this is necessary */
@@ -2478,7 +2478,7 @@ void Curl_multi_closed(struct connectdata *conn, curl_socket_t s)
if(entry) {
if(multi->socket_cb)
- multi->socket_cb(conn->data, s, CURL_POLL_REMOVE,
+ multi->socket_cb(data, s, CURL_POLL_REMOVE,
multi->socket_userp,
entry->socketp);