"Connection is still name resolving, can't reuse" error
Date: Fri, 8 May 2020 15:37:16 -0700
Hello,
I am trying to use the share interface to share connection among threads,
and keep encountering " Connection # is still name resolving, can't reuse"
error.
Here is what I did. I am sorry that some of the codes are skipped due to
the complexity of my application. I pretty much followed the example.
https://curl.haxx.se/libcurl/c/shared-connection-cache.html
1. Initialize a static CURLSH pointer.
cshare = curl_share_init();
2. Set the lock/unlock and connect options.
curl_share_setopt(cshare, CURLSHOPT_LOCKFUNC, lock);
curl_share_setopt(cshare, CURLSHOPT_UNLOCKFUNC, ulock);
curl_share_setopt(cshare, CURLSHOPT_SHARE, CURL_LOCK_DATA_CONNECT);
3. When a new threads runs the application, it creates a new easy handle
and use the share curl.
curl_easy_setopt(handle, CURLOPT_SHARE, cshare)
4. I run the application, and the below is the logging messages. I am
pasting the message from the very first curl handle.
STATE: INIT => CONNECT handle 0x7ffea00742c0;
...
*Added connection 0. The cache now contains 1 members.*
...
STATE: CONNECT => WAITRESOLVE handle 0x7ffea00742c0; (connection #0)
...
STATE: WAITRESOLVE => WAITCONNECT handle 0x7ffea00742c0; (connection #0)
...
*Connected to SANITIZED.com () port 443 (#0)*
...
STATE: WAITCONNECT => SENDPROTOCONNECT handle 0x7ffea00742c0; (connection
#0)
...
STATE: SENDPROTOCONNECT => PROTOCONNECT handle 0x7ffea00742c0; (connection
#0)
...
STATE: PROTOCONNECT => DO handle 0x7ffea00742c0; (connection #0)
...
STATE: DO => DO_DONE handle :0
n; (connection #0)
...
STATE: DO_DONE => PERFORM handle 0x7ffea00742c0; (connection #0)
...
STATE: PERFORM => DONE handle 0x7ffea00742c0; (connection #0)
...
*Connection #0 to host SANITIZED.com left intact*
...
my debug messages : old: DONE, new: COMPLETED, handle: 0x7ffea00742c0
...
my debug messages : old: COMPLETED, new: MSGSENT, handle: 0x7ffea00742c0
...
*Connection #0 is still name resolving, can't reuse* // This is logged
when another thread is trying to re-use the connection #0.
Based on the log messages above, when I see "connection #0. to host ## left
intact", I believe it basically means the connection becomes the state that
can be re-used by other threads.
However, when another easy handle (another thread) is trying to use the
connection #0, it says the connection #0 is still name resolving, and this
error persists until my application ends.
This symptom happens for the rest of the threads. keep getting "Connection
# is still name resolving, can't reuse" error messages. None of the
connections is being re-used.
I am very new to libcurl, so I may be missing something here. I would very
much appreciate if anyone can pinpoint where I can take a look to diagnose
this.
Best,
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2020-05-09