cURL / Mailing Lists / curl-library / Single Mail

curl-library

questions about multi API

From: Mohun Biswas <m_biswas_at_mailinator.com>
Date: Mon, 29 Jun 2009 12:26:22 -0400

I have a few questions about the multi API, even after reading the
documentation:

- The doc states that curl_multi_perform "will only execute as little as
possible and then return back control to your program". Taken literally
this would mean it transfers one byte with each "ready" socket, but I'm
guessing it really means that one buffer's worth is exchanged, and
return CURLM_CALL_MULTI_PERFORM if more could be done?

- 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? In other words I think I shouldn't use the above loop if my
program has other high-priority things to do?

- Is there a technique for "serializing" the multi API? By which I mean
something like a flag to change the "as little as possible" philosophy
to "as much as possible", which would make it behave much more
synchronously like the easy API. I'm thinking this could be useful for
debugging. For instance, I've completely rewritten my own program to use
multi and, predictably, there are bugs. It's not clear to what degree
these are caused by asynchrony itself (race conditions, etc) or simply
mistakes introduced in the rewrite. Seems to me that serializing could
be a great divide-and-conquer approach.

Thanks,
MB
Received on 2009-06-29