cURL / Mailing Lists / curl-library / Single Mail


RE: CURLMOPT_TIMERFUNCTION not called when last timer cancelled

From: David Lasker <>
Date: Mon, 23 Jun 2008 13:52:37 -0700

Sorry, there was a typo on my original question. I am talking about the lack
of timer callback after the connection completes, not the dns lookup. To
avoid confusion, I am re-submitting the question with the correct wording...

I start up a bunch of http transfers in parallel. Then, the following occurs
after completion of the final connection to the remote web server:

curl_multi_socket_action calls update_timer
   update_timer calls multi_timeout
      multi_timeout sets timeout_ms to -1, since multi->timetree is NULL
   update_timer returns without calling the timer callback
            (multi.c line 1937), since timeout_ms < 0

As a result, my timer callback function is never called after the final
connection is made. This creates problems, since my code erroneously
continues to use the result from libcurl's previous call to my timer
callback. I would like to get one final call of my timer callback function
with timeout_ms set to -1.

I believe that update_timer should check for this, and call multi->timer_cb
the first time that multi_timeout sets timeout_ms to -1.

I have worked around this problem by abandoning the timer callback
mechanism, calling curl_multi_timeout directly just before my select, and
taking appropriate action when it sets timeout_ms to -1.

Is there a way around this (short of patching libcurl) that would allow me
to detect when the last timer is cancelled while using

Thanks for the help!

Received on 2008-06-23