cURL / Mailing Lists / curl-library / Single Mail


Re: questions about multi API

From: Mohun Biswas <>
Date: Wed, 01 Jul 2009 05:22:23 -0400

Hardeep Singh wrote:
> On Mon, Jun 29, 2009 at 10:46, Daniel Stenberg<> wrote:
>> On Mon, 29 Jun 2009, Mohun Biswas wrote:
>>> - The docs also say "It is designed to never block". A common idiom
>>> mentioned in the docs and used often in the examples is to call
>>> curl_multi_perform in a loop:
>>> while (CURLM_CALL_MULTI_PERFORM == curl_multi_perform(...));
>>> if I understand correctly, this will will treat all easy handles "fairly"
>>> without blocking, but will effectively "block" any non-curl-related activity
>>> until all curl transfers are done. Is that right?
>> Sure, but that while() is in the app not in libcurl.
> For the reason that this loop is in the app, a separate thread can be
> launched to run this loop and doesn't block the rest of the app...
> Does this eliminate the need for serializing?

Not sure if this point is addressed to me or Daniel but in any case the
libcurl docs say about threading "The first basic rule is that you must
never share a libcurl handle (be it easy or multi or whatever) between
multiple threads". So I don't think this is an option.

And as Daniel points out the loop is not required, it's just quite
common. I guess the point is it's the right thing to do iff all your
important work is being done by the libcurl multi API.

Received on 2009-07-01