cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: CURLMOPT_TIMERFUNCTION not called when last timer cancelled

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 24 Jun 2008 12:05:21 +0200 (CEST)

On Mon, 23 Jun 2008, David Lasker wrote:

>> You use curl_multi_socket() with select() ?
>
> Yes I do.

When using select() I personally would prefer using curl_multi_timeout()
anyway as that'll be easier than using the callback and keeping track of the
timeout time on my own.

> My application reads N records from an database and then performs N HTTP
> posts in parallel using curl_multi_socket_action. Since the only sockets
> involved are those used for HTTP, I didn't see any point in using libevent,

The fact that they are used only for HTTP is not a good argument against using
an event based system. curl_multi_socket* is an API that allows high
performance simply because it is event-based and allows you to avoid select().

Then, libcurl may also deal with other sockets even when you do HTTP only,
like for example the name resolve if you have built it with c-ares support.

> so I do my own select. I use CURLMOPT_SOCKETFUNCTION to tell my select which
> FD's to look for.

If using select, I would rather use curl_multi_setfd() as that too would put
less work in the app.

> Is there a better way to implement this?

Well, since you use select() I see little reason to use curl_multi_socket* and
you could probably get away with curl_multi_perform() and get a simpler
application. But the way you do it should still work...

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