cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: [curl] curl_multi_fdvec (#38)

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Mon, 27 Aug 2012 22:56:42 +0200 (CEST)

On Mon, 27 Aug 2012, Sara Golemon wrote:

>> int curl_multi_wait(CURLM *multi_handle,
>> struct curl_waitfd fds[],
>> int nfds,
>> int timeout_ms);
>>
>> This is meant to be very similar to poll() although it uses a
>> curl-specific struct.

> Absolutely fine with that. I considered something close to this (but using
> poll's struct)

I figured we want this function provide even for some platforms that lack (a
proper) poll and the proper structs and defines in "real" headers, so we'd
have to provide our own struct for those anyway.

> initially, but thought that wouldn't meet the test of being able to specify
> custom events flags (which I don't need personally, but I know you like more
> general use functionality).

Yeah, it would still be a bit limited but I would guess quite possibly still
good enough.

An alternative approach would be to instead provide a function that returns
the info and make the application do the actual call to poll() or whatever. It
would basically be the poll() version of curl_multi_fdset(). Something like:

   int curl_multi_pollset(CURLM *multi_handle,
                          struct curl_pollset **fds);

It would return the size of the returned 'fds' array, which then would be the
amount of file descriptors exported from libcurl. An application would then
use the file descriptors to populate the pollfd structs before calling poll(),
but it could also use whichever method it wants.

It gives even more flexibility but will force the application to do more work
and basically all applications that'd use this would like to use poll() so
they would all be forced to implement the same logic all over...

I think I prefer the first version. Possibly we can call it curl_multi_poll()
since it resembles poll so much.

> I'll put together a new pull request based on this API (unless you tell me
> you're working on it alread).

It'd be great if you could. And thanks for your patience and understanding for
my testing various ways against each other!

(Of course, if there's anyone else reading this who has opinions in the
matter, please speak up your mind!)

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2012-08-27