Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Phantom socket with threaded resolver

From: Sean Miller via curl-library <curl-library_at_cool.haxx.se>
Date: Fri, 9 Oct 2020 20:50:43 +0000 (UTC)

Hello again, libcurl experts. I'm using libcurl's threaded resolver. A trimmed log excerpt follows:

19:39:19,837 DEBUG [libcurl_multi_wrapper] - adding easy handle
19:39:19,837 DEBUG [http_client] - on_libcurl_multi_timer(timeout_ms=0)
19:39:19,837 DEBUG [http_client] - on_timeout
19:39:19,837 DEBUG [libcurl_multi_wrapper] - performing socket action; fd=-1, event_bitmask=0
19:39:19,838 DEBUG [http_connection] - from libcurl: STATE: INIT => CONNECT handle 0x7f6d70000ad8; line 1491 (connection #-5000)
19:39:19,838 DEBUG [http_connection] - from libcurl: Added connection 0. The cache now contains 1 members
19:39:19,838 DEBUG [http_connection] - from libcurl: STATE: CONNECT => WAITRESOLVE handle 0x7f6d70000ad8; line 1532 (connection #0)
19:39:19,838 DEBUG [http_client] - on_libcurl_multi_socket(sock=11, what=IN)
19:39:19,838 DEBUG [libcurl_socket_manager] - watch(sock=11, action=IN)
19:39:19,838 WARN  [libcurl_socket_manager] - asked to watch unmanaged socket

Here, I add an easy handle to a multi handle and call curl_multi_socket_action() with CURL_SOCKET_TIMEOUT and event 0 to kick off the transaction.

In response, libcurl appears to create a socket for DNS resolution without asking for it via CURLOPT_OPENSOCKETFUNCTION. Unfortunately, my side of the program isn't aware of that socket and so cannot watch it for read-readiness as requested. Subsequently, libcurl requests a series of timeouts of increasing duration, which typically delay the first transactions by 64-256 ms.

Compiling libcurl with --disable-threaded-resolver removes the WAITRESOLVE state, and, therefore, the phantom socket.

Is this behavior intentional? Is there a recommended way to either force libcurl to ask for the socket, or else avoid telling me about it? Where did I go wrong?

Regards,
Sean M.

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2020-10-09