Winbindd limited by select
mike at easysw.com
Sat Feb 15 14:05:39 GMT 2003
Michael Steffens wrote:
> I'm wondering, basically concerning all platforms, whether this
> is about the size of fd_set, or about the number of FDs the
> kernel will actually assign to a process.
> If the latter one is not limited, wouldn't a single excessive FD
> consumer impact other processes?
Some OS's have a hard limit (typically 1024 file descriptors, but
some have a smaller limit), while others allow for greater numbers
of file descriptors. In both cases, the current process file
descriptor limit (see "man getrlimit" and "man setrlimit") is used
to determine how many file descriptors are allowed/allocated. As
for the actual memory footprint of a process, I don't know if most
kernels use a static allocation or if they dynamically increase the
size of the fd table as needed by the process...
CUPS now uses getrlimit and setrlimit to query/manipulate the
maximum number of file descriptors, and then allocates a fd_set
buffer of the appropriate size for the number of file descriptors.
The only platform we've had to make adjustments for has been MacOS
X, which reports a rlim_max value of 2^32-1; our original
implementation would then try to set the limit to that value and
allocate fd_set's. Apple quickly pointed this out to us when they
tested the latest CVS :), and we now have a configure-time maximum
that is used as a limit when the kernel reports a larger maximum -
this also allows us to tailor CUPS for smaller or larger servers,
without impacting the default configuration (which continues to
behave exactly as before...)
Sooo, my recommendations are as follows:
1. Provide a configure option (--with-maxfiles or similar)
to configure the upper limit you want to support in SAMBA.
2. Provide a smb.conf option to control the max number of
3. Provide a definition on Solaris for FD_SETSIZE before
including <sys/select.h> so that the correct version of
select() is used.
4. On startup, query the current FD limit and set it to the
smaller of the "maxfiles" definition, the max value
reported by the kernel, and the max value in smb.conf.
5. Allocate the fd_set buffers [(maxfiles + 7) / 8 bytes]
and replace all use of FD_ZERO with memset/bzero with
the correct size.
6. Make sure all calls to FD_SET and FD_CLR are updated to
not use "&set", since "set" is now allocated.
Michael Sweet, Easy Software Products mike at easysw.com
Printing Software for UNIX http://www.easysw.com
More information about the samba-technical