cURL / Mailing Lists / curl-library / Single Mail

curl-library

CURLMOPT_TIMERFUNCTION not called when last timer cancelled

From: David Lasker <dave_at_altosdesign.com>
Date: Mon, 23 Jun 2008 12:32:33 -0700

Hopefully this is my final dumb question on libcurl timing...

I start up a bunch of http transfers in parallel. Then, the following occurs
after completion of the final DNS lookup:

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 DNS
lookup completes. 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
CURLMOPT_TIMERFUNCTION?

Thanks for the help!

Dave
Received on 2008-06-23