cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Bug in curl multi DONE->COMPLETED state transition?

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 6 Aug 2008 23:24:00 +0200 (CEST)

On Wed, 6 Aug 2008, Albert Lee wrote:

> It appears that our curl stack was actually not handling timeouts correctly
> - it is not entirely clear from the documentation, and unfortunately several
> other consumers of libcurl have misinterpreted it as well. We used on the
> CURLM_TIMERFUNCTION callback to synchronously schedule timeouts for us, and
> so we completely forgot the timeout when the value didn't change.

Well, in my mind event-based systems such as the multi_socket API are all
about only telling about changes - so unless something changes the former
situation still stands. Sort of...

> The documentation should probably state that timeouts should be scheduled
> asynchronously outside the callback (unlike curl_multi_timeout)

Really? how else can a timeout be scheduled? _within_ the callback?

I'd be happy if you would write a full sentence/replacement for the manual
that would clarify this behavior in your eyes.

> and specify whether -1 should be handled the same way as for
> curl_multi_timeout (that is, set an arbitrarily long timeout instead of no
> timeout).

Actually, in the callback case the -1 is actually no timer at all. For real.

> BTW, the curl_multi_timeout manual still refers to an nonexistant 'easy'
> argument for curl_multi_socket.

Aha, thanks for pointing this out. I'm editing it just now.

> I'm guessing timeouts should be scheduled in the same part of the event loop
> where one would normally call curl_multi_timeout, i.e. right before we
> listen for new events.

curl_multi_timeout() would not normally be used when you use the
curl_multi_socket* API, as it is inadequate for providing the necessary
functionality.

But yes, your event-loop should wait for events and timeouts, and libcurl will
tell you whenever there's a change in what actions or file descriptors to wait
for, or when there's an updated timeout timer to set.

> Unfortunately our event loop is totally isolated from the curl code, which
> is only invoked when handling events on specific sockets.

You "just" need to add timeout functionality to it as well...

-- 
  / daniel.haxx.se
Received on 2008-08-06