You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Mladen Turk <mt...@apache.org> on 2005/04/16 08:38:39 UTC

Seting FD_SETSIZE on WIN32

Hi,

Can we set the FD_SETSIZE to a higher number then 64
on Windows platform?
Here is what docs say:
The default value of FD_SETSIZE is 64, which can be modified by defining 
FD_SETSIZE to another value before including Winsock2.h

So, I'd like that we define the FD_SETSIZE to a 1024, like its defined
on most other platforms (POSIX). I've tested that with really high
values (16384), and the select works fine.

Any objections for committing that?

Regards,
Mladen.

Re: Seting FD_SETSIZE on WIN32

Posted by Mladen Turk <mt...@apache.org>.
William A. Rowe, Jr. wrote:
> Feel free to research; the issue is the underlying calls to
> [WSA]WaitForEventOrTimeout ... Windows can't poll more than
> 64 handles + timeout event.
>

Well, I have tested by precompiling the APR with FD_SETSIZE set
to 16384, and didn't find any issues.

Actually it can poll huge number of sockets from apr_pollset.
We have implementation for Tomcat (jakata-tomcat-connectors/jni)
that uses APR for polling keepalive sockets.
We have tests with 2000 concurrent connections hanging in the
poll served with 100 threads.
So I suppose that the select() uses something different
then WaitForMultipleObjects internally.

Regards,
Mladen.

RE: Seting FD_SETSIZE on WIN32

Posted by James Mansion <ja...@wgold.demon.co.uk>.
>Feel free to research; the issue is the underlying calls to
>[WSA]WaitForEventOrTimeout ... Windows can't poll more than
>64 handles + timeout event.

Well, yes, but that's only an issue if you use the Win32 APIs
the wrong way.

Don't put socket handles in the Wait array.

Hopefully it can be rescued without the surgery that a change
to an IOCP structure would mean:

* create an array of event objects, some convenient prime in
  size <64
* for each (async) IO request against a socket, use the overlapped
  IO facility, and hash a structure for the IO randomly across
  these event objects
* maintain a list of requests against each event where we
  contain the OVERLAPPED structures with their hEvent set to
  the associated event
* WaitForMultipleObjects return will tell you which request list
  to search
* check the completion status of each OVERLAPPED structure.

Alternatively use the completion routine facility and receive
notification by APCs.

Windows can manage socket IO across lots of sockets.  This
perceived limitation is only an issue because people familiar
with select(0 or poll() expect to use the WaitForMulti the same
way.  You can, but only with this limitation.  We shouldn't
blame Microsoft if people don't read and understand the API.

James




Re: Seting FD_SETSIZE on WIN32

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
Feel free to research; the issue is the underlying calls to
[WSA]WaitForEventOrTimeout ... Windows can't poll more than
64 handles + timeout event.

Bill

At 01:38 AM 4/16/2005, Mladen Turk wrote:
>Hi,
>
>Can we set the FD_SETSIZE to a higher number then 64
>on Windows platform?
>Here is what docs say:
>The default value of FD_SETSIZE is 64, which can be modified by defining FD_SETSIZE to another value before including Winsock2.h
>
>So, I'd like that we define the FD_SETSIZE to a 1024, like its defined
>on most other platforms (POSIX). I've tested that with really high
>values (16384), and the select works fine.
>
>Any objections for committing that?
>
>Regards,
>Mladen.