cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Extacting FDs higher than FD_SETSIZE from the multi interface

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Mon, 11 Feb 2013 13:48:54 +0100 (CET)

On Mon, 11 Feb 2013, Shoal, Aaron wrote:

> I'm working on a load tool that simulates several thousands of users, each
> issuing HTTP requests concurrent to one another.
>
> I've elected to use poll() due to the large number of concurrent
> connections.

Allow me to point out that poll() is a crappy way to work with that many
connections[*]. The overhead in each poll call is significant.

The high performance way is to use an event-based backend.

> Prior to release 7.23.0, Curl_multi_fdset() didn't check for FD_SETSIZE.
> That allowed me to extract FDs higher than FD_SETSIZE by checking the value
> of maxfd after calling that function, which I would do after sending a new
> HTTP request. In 7.23.0 a check for FD_SETSIZE was added to prevent
> overflow when bits of the passed-in fd_set were set. I was compensating for
> that in my code with a buffer.
>
> Obviously curl has no problem using FDs with values higher than FD_SETSIZE,
> but how do I obtain those FDs for use with my polling implementation?

curl_multi_socket_action() is libcurl's primary function to use when driving
it event based. It will then tell you which sockets it uses with a callback
and you tell it which socket that has "activity".

If you rather still want the slower approach, you can avoid the FD_SETSIZE
dilemma by using the recently introduced curl_multi_wait() which will do the
poll() for you.

[*] = http://daniel.haxx.se/docs/poll-vs-select.html

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2013-02-11