curl / Mailing Lists / curl-library / Single Mail
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.

Re: curl_multi_timeout and the multi_socket API

From: Daniel Stenberg via curl-library <curl-library_at_cool.haxx.se>
Date: Sun, 4 Apr 2021 12:28:53 +0200 (CEST)

On Sat, 3 Apr 2021, Henrik Holst wrote:

(Let me just add some meat to this and explain this described behavior.)

> As I wrote earlier, usually when you call curl_multi_add_handle(), the Timer
> Function CB is called once by curl with timeout set to 0. Then when you call
> curl_multi_socket_action() with CURL_SOCKET_TIMEOUT the Timer Function CB is
> usually called once more but this time with a timeout set to 1.

This description matches how libcurl *did* behave. More recent versions don't
need to poll the name resolve results from the threaded resolver so the
timeout pattern will be slightly different.

The application should of course still be prepared to deal with the timeouts
libcurl asks for.

> If you do not call curl_multi_socket_action() again with CURL_SOCKET_TIMEOUT
> after 1ms then curl stalls indefinitely since there will be no read or write
> events triggering the event handler to return events,

... because in that scenario libcurl waits to get called so that it can poll
if the name resolve is done, and if you don't call libcurl then it won't
notice that and it can't continue to perform its transfer until that's done!

-- 
  / daniel.haxx.se
  | Commercial curl support up to 24x7 is available!
  | Private help, bug fixes, support, ports, new features
  | https://www.wolfssl.com/contact/
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html
Received on 2021-04-04