After even more studying of the sys/types.h header, I could see a MAJOR problem with 
the way fd_set is defined. It appears that this structure is defined as a wrapper 
around an array of bytes, the number of which determined by the FD_SETSIZE macro. The 
length of this is computed at COMPILE TIME.

What's worse, the various macros like FD_ZERO, and friends do not do any sort of 
bounds checking. This means that when I called FD_SET() with a descriptor value 
greater than FD_SETSIZE, I was actually over-running a buffer. Talk about subtle!!! 

To fix this, I could simply #define my own value of FD_SETSIZE so that the size of the 
array is computed large enough to handle all the descriptors I need. (Adding a -D to 
my makefile).

Caveat programmer...





-----Original Message-----
From: Geoff Thorpe <[EMAIL PROTECTED]>
Sent: Jul 29, 2004 12:34 PM
To: [EMAIL PROTECTED]
Subject: Re: max sessions

On July 29, 2004 02:20 pm, Joseph Bruni wrote:
> The other thing I noticed was that (according to the man page for
> select()) the results of the FD_ macros are undefined if the descriptor
> value is greater than FD_SETSIZE, which is 1024 on my system. I find
> this odd since the hard limit of the number of files any given process
> can have open is kern.maxfilesperproc = 10240. Is this a limitation of
> the POSIX API or could the man page for select() be wrong? Does anyone
> have any insight into the proper use of select() if the descriptor
> values are larger than FD_SETSIZE? Or maybe some other function that
> replaces select() for programs with LOTS of descriptors?

I don't know which system you're runing, but perhaps you might have more 
luck with poll(2)?

Cheers,
Geoff
-- 
Geoff Thorpe
[EMAIL PROTECTED]
http://www.geoffthorpe.net/

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to