[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: 1024 fd limit ?

Luc Saillard a écrit :
> If you look in the openldap source, you will find that openldap look for some
> value (OPEN_MAX).
> localhost:/home/luc/srcs/openldap/openldap-2.0.7>grep OPEN_MAX -r .
> clients/finger/main.c:  tblsize = sysconf( _SC_OPEN_MAX );
> clients/gopher/go500.c: dtblsize = sysconf( _SC_OPEN_MAX );
> clients/gopher/go500gw.c:       dtblsize = sysconf( _SC_OPEN_MAX );
> libraries/libldap/os-ip.c:      tblsize = sysconf( _SC_OPEN_MAX );
> libraries/libldap_r/os-ip.c:    tblsize = sysconf( _SC_OPEN_MAX );
> libraries/liblutil/detach.c:    nbits = sysconf( _SC_OPEN_MAX );
> servers/slapd/daemon.c: dtblsize = sysconf( _SC_OPEN_MAX );
> So perhaps, you need to modify the file limit.h in the kernel source and change
> this line
> #define OPEN_MAX         256 /* # open files a process may have */

On Unix, limits for system resources (cputime, filesize, datasize,
stacksize, coredumpsize, memoryuse, descriptors, memorylocked, maxproc,
openfiles) are generally not hard coded for all processes, you can
change this at runtime and per process.
Take a look at the man page for 'sysconf' and you get: SYNOPSIS: long
sysconf (int name);

So the parameter for sysconf (i.e. _SC_OPEN_MAX in our case) is not the
actual value but the reference to this value.

To change the limits system ressources you need to use the shell command
'ulimit' in sh/bash (or 'limit' for csh/tcsh).
'ulimit -n' to get the current limit and 'ulimit -n 2048', 'ulimit -n
unlimited' or 'ulimit -nH' (max value) to set the limit

If you use tcsh, the command is more simple to understand:
'limit' and you get on Linux 2.2.17 i686:

cputime         unlimited
filesize        unlimited
datasize        unlimited
stacksize       8192 kbytes
coredumpsize    unlimited
memoryuse       unlimited
descriptors     1024 
memorylocked    unlimited
maxproc         256 
openfiles       1024 

Now, depending on the OS, a limit can have a max value (that may be
configured in the kernel).
You may also have reach the limit handled by the select systemcall
(__FD_SETSIZE). In any case you should never change the include files..

If you are using Linux 2.2, you may need to patch your kernel to go
beyond 1024 (using Alan Cox's patches)..