curl / Mailing Lists / curl-library / Single Mail

curl-library

Re: unexpected code 35 (if tcp listen backlog is full)

From: Ray Satiro via curl-library <curl-library_at_cool.haxx.se>
Date: Sat, 13 Jan 2018 16:01:22 -0500

On 1/13/2018 4:16 AM, Michael Kilburn via curl-library wrote:
> CentOS 7
> libcurl 7.54 compiled with OpenSSL
>
>
> I am observing strange behavior -- when server's TCP backlog is
> overflowing I naturally start getting curl code 7. But I also get curl
> code 35 and (as time goes by) they become more and more prevalent
> (after 1-2 hours). It looks like a bug to me -- I shouldn't get
> anything TLS-specific until TCP connection is established.
> Sufficiently increasing server's TCP backlog size makes both problems
> to go away. Is it normal?
>
> Client app has ~30-60 threads each performing more or less the same
> operation in a loop (with some delay in-between):
>      curl_easy_init()
>      configure handle to send a POST request to https endpoint
>      curl_easy_perform()
>      curl_easy_cleanup()  -- I know it is inefficient

"I shouldn't get anything TLS-specific until TCP connection is established."

How do you know it isn't established, did you check? I suppose there's a
very slight chance that error may bubble up for some related reason such
as out of random bits so I guess that's possible. Turn on
CURLOPT_VERBOSE [1] which should show the extended error information or
use CURLOPT_ERRORBUFFER [2].

"curl_easy_cleanup()  -- I know it is inefficient"

Yes. Typically you'd have a multi handle which shares the connection
cache. In the most recent version of libcurl it's possible to share a
connection cache between easy handles without using a multi handle by
protecting that resource using CURL_LOCK_DATA_CONNECT [3] and then
sharing that with each easy handle. However it's a new feature and some
bugs were recently fixed that haven't made it to release yet. If you are
interested in trying it wait until the release of 7.58 in two weeks.

this once:
CURLSH *connshare = curl_share_init();
curl_share_setopt(connshare, CURLSHOPT_SHARE, CURL_LOCK_DATA_CONNECT);
curl_share_setopt(connshare, CURLSHOPT_LOCKFUNC, lock);
curl_share_setopt(connshare, CURLSHOPT_UNLOCKFUNC, unlock);

and in each easy handle:
curl_easy_setopt(curl, CURLOPT_SHARE, connshare);

Also please read about libcurl thread safety [4].

[1]: https://curl.haxx.se/libcurl/c/CURLOPT_VERBOSE.html
[2]: https://curl.haxx.se/libcurl/c/CURLOPT_ERRORBUFFER.html
[3]: https://curl.haxx.se/libcurl/c/curl_share_setopt.html
[4]: https://curl.haxx.se/libcurl/c/threadsafe.html

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2018-01-13