cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Blocking variant of curl_multi_perform

From: Olaf van der Spek <olafvdspek_at_gmail.com>
Date: Sat, 6 Mar 2010 17:34:29 +0100

On Sat, Mar 6, 2010 at 5:14 PM, Daniel Stenberg <daniel_at_haxx.se> wrote:
> On Sat, 6 Mar 2010, Olaf van der Spek wrote:
>
>>> Not until at least someone else also speaks up in favour of it. Then
>>> there's
>>> of course the issue of how an API for such a function would work, and
>>> then
>>> I'm mostly thinking about how the app would know how each individual
>>> transfer did.
>>
>> In the same way as now?
>
> That's doable, but your suggested code would also need to know when all
> transfers are done and if it wants to leave the messages for the app to read
> out, the function cannot also consume those messages. It'd require some care
> to address it, like to be able to "push back" a message to the multi message
> queue.

Not really. Something like this should do:

CURLMsg* curl_multi_perform_sync(CURLM* curl_multi)
{
        fd_set read;
        fd_set write;
        fd_set except;
        FD_ZERO(&read);
        FD_ZERO(&write);
        FD_ZERO(&except);
        int max_fd;
        curl_multi_fdset(curl_multi, &read, &write, &except, &max_fd);
        timeval timeout;
        timeout.tv_sec = 1;
        timeout.tv_usec = 0;
        select(max_fd + 1, &read, &write, &except, &timeout);
        int running_handles;
        curl_multi_perform(curl_multi, &running_handles);
        int msgs_in_queue;
        return curl_multi_info_read(curl_multi, &msgs_in_queue);
}
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-03-06