ares: remove fd from multi fd set when ares is about to close the fd 59/219159/1
authorNiraj Kumar Goit <niraj.g@samsung.com>
Mon, 2 Dec 2019 10:04:23 +0000 (15:34 +0530)
committerNiraj Kumar Goit <niraj.g@samsung.com>
Mon, 2 Dec 2019 10:04:23 +0000 (15:34 +0530)
commit8dfb92873af9de5d883e191e0097be32c78a7d0f
treeec619f6ddeeaa4d21e167ca36e5f4182e91091c6
parentbfd1c3da373e54e8ee7adecaa5cbe8b70686f727
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

Backported patch details:
https://github.com/curl/curl/commit/6765e6d9e6a32bb4fc666d744cb57e2d55d4e13b

Change-Id: I62b2d244cb0f38a4c4a76ad804c7fd69f9222484
Signed-off-by: Niraj Kumar Goit <niraj.g@samsung.com>
lib/asyn-ares.c
lib/asyn-thread.c
lib/asyn.h
lib/connect.c
lib/easy.c
lib/multi.c
lib/multiif.h
lib/url.c