[AGENT++] Select()/FD_SETSIZE issues in the Agent++ implementation

Razvan Cojocaru razvan.cojocaru at kaspersky.ro
Thu Oct 11 15:48:35 CEST 2007


Hello.

Using select() is potentially error-prone, as on most UNIX systems
(Linux included) there's a limit for the highest numbered file
descriptor usable in a fd_set. This number is FD_SETSIZE, and it's
usually defined in /usr/include/bits/typesizes.h as 1024.

For more information, please see:

http://www.delorie.com/gnu/docs/glibc/libc_248.html

"Macro: int FD_SETSIZE
    The value of this macro is the maximum number of file descriptors
that a fd_set object can hold information about. On systems with a fixed
maximum number, FD_SETSIZE is at least that number. On some systems,
including GNU, there is no absolute limit on the number of descriptors
open, but this macro still has a constant value which controls the
number of bits in an fd_set; if you get a file descriptor with a value
as high as FD_SETSIZE, you cannot put that descriptor into an fd_set."

Now, theoretically it is possible to use Agent++ from an application
that uses more than 1024 file descriptors, or simply somehow comes
across file descriptor #1027.

See also the following thread:

http://groups.google.com/group/comp.unix.programmer/browse_thread/thread/867003a37e7c8e8e/c943c8abb2801c37?hl=en&lnk=st&q=select+FD_SETSIZE&rnum=11#c943c8abb2801c37

So is using select() in Agent++/AgentX++/SNMP++ safe (am I missing
something you've done about this issue)? Or will you consider using
poll() which seems to be the safe choice?



More information about the AGENTPP mailing list