cURL / Mailing Lists / curl-library / Single Mail

curl-library

CURLMOPT_TIMERFUNCTION

From: Joe Eggleston <joe_at_arbor.net>
Date: Fri, 11 Sep 2009 15:50:42 -0400

Hi all,
I have a some questions about proper implementation of the callback
for the multi option CURLMOPT_TIMERFUNCTION.

The docs say the following:

"This function will then be called when the timeout value changes. The
timeout value is at what latest time the application should call one
of the "performing" functions of the multi interface
(curl_multi_socket(3), curl_multi_socket_all(3) and
curl_multi_perform(3)) - to allow libcurl to keep timeouts and retries
etc to work. A timeout value of -1 means that there is no timeout at
all, and 0 means that the timeout is already reached. Libcurl attempts
to limit calling this only when the fixed future timeout time actually
changes."

My questions:
1. Is it safe to assume that curl will only schedule one timeout at a
time? So, if the callback is called with a positive timeout request, I
can safely delete/replace any previously scheduled pending timeout?
2. Does curl expect timeouts to be persistent? I.e., if the timeout
occurs, should a new timeout be scheduled using the previously
specified timeout value? Or, can I assume that curl will call the
callback to explicitly schedule a new timeout?
3. What's the difference in behavior between timeouts of 0 and -1? I
assume that -1 means I should delete any scheduled timeout. Does 0
imply the same, but in addition I should call
curl_multi_socket_action() with CURL_SOCKET_TIMEOUT? If so, why
wouldn't curl just handle this internally?

Thanks!
Joe
Received on 2009-09-11