OVDB Too many open files

Per Hedeland per at erix.ericsson.se
Thu Apr 13 21:47:14 UTC 2000


Russ Allbery <rra at stanford.edu> wrote:
>Per Hedeland <per at erix.ericsson.se> writes:
>
>> Innd is a heavy user of select(), and Bad Things will happen if you try
>> to use fds > 1023 with select() pre Solaris 7... (perhaps this might
>> even be the *cause* of your problems).
>
>Yeah, if I recall correctly, the FD_*() macros will happily scribble all
>over memory if you try to initialize an fd_set that's larger than 1024.

Not quite, but worse...:-) If you don't redefine FD_SETSIZE, an fd_set
can't *be* larger than 1024 - but if you give fds >= FD_SETSIZE to the
macros, this will indeed happen (it will with most all implementations,
I'd say). But that's just the tip of the iceberg - you're violating the
API spec by doing this, and have only yourself to blame (though of
course it's typically the *user*, not the programmer, that makes it
happen:-).

But the Solaris 2.5.1 select() man page, like many others, claims that
you can just redefine FD_SETSIZE to get a bigger fd_set. And you can,
and giving fds > 1023 but smaller than the new FD_SETSIZE won't scribble
over random memory then - but select() *itself* will! Of course it's
just a wrapper around poll(), and to do its housekeeping when mapping
from select() to poll() and back, it uses a couple of fd_sets or three -
and the size of *those* won't change no matter what you #define in your
program, of course... At least the man page is fixed in 2.6.:-)

--Per Hedeland
per at erix.ericsson.se




More information about the inn-workers mailing list