diff options
author | Jeremy Allison <jra@samba.org> | 1998-12-11 21:12:52 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 1998-12-11 21:12:52 +0000 |
commit | f2ff57d5611f5756fe3558c8efc7f77014ff000c (patch) | |
tree | 64c2ceaf2dd49b6d81cdf5c2b6f324705868c62e /source/lib | |
parent | d45be1540395d5245395e753a8a1d83937c6667f (diff) | |
download | samba-f2ff57d5611f5756fe3558c8efc7f77014ff000c.tar.gz samba-f2ff57d5611f5756fe3558c8efc7f77014ff000c.tar.xz samba-f2ff57d5611f5756fe3558c8efc7f77014ff000c.zip |
Fixed file descriptor limit code for AIX 4.x. AIX doesn't support the
fd limits and always returns RLIM_INFINITY for a RLIMIT_NOFILE query.
Jeremy.
Diffstat (limited to 'source/lib')
-rw-r--r-- | source/lib/util.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/source/lib/util.c b/source/lib/util.c index bb29062cea3..03e85a8090a 100644 --- a/source/lib/util.c +++ b/source/lib/util.c @@ -2866,34 +2866,50 @@ int set_maxfiles(int requested_max) { #if (defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE)) struct rlimit rlp; + int saved_current_limit; + if(getrlimit(RLIMIT_NOFILE, &rlp)) { DEBUG(0,("set_maxfiles: getrlimit (1) for RLIMIT_NOFILE failed with error %s\n", strerror(errno) )); /* just guess... */ return requested_max; } - /* Set the fd limit to be real_max_open_files + MAX_OPEN_FUDGEFACTOR to + + /* + * Set the fd limit to be real_max_open_files + MAX_OPEN_FUDGEFACTOR to * account for the extra fd we need * as well as the log files and standard - * handles etc. */ - rlp.rlim_cur = MIN(requested_max,rlp.rlim_max); + * handles etc. Save the limit we want to set in case + * we are running on an OS that doesn't support this limit (AIX) + * which always returns RLIM_INFINITY for rlp.rlim_max. + */ + + saved_current_limit = rlp.rlim_cur = MIN(requested_max,rlp.rlim_max); if(setrlimit(RLIMIT_NOFILE, &rlp)) { DEBUG(0,("set_maxfiles: setrlimit for RLIMIT_NOFILE for %d files failed with error %s\n", (int)rlp.rlim_cur, strerror(errno) )); /* just guess... */ - return requested_max; + return saved_current_limit; } if(getrlimit(RLIMIT_NOFILE, &rlp)) { DEBUG(0,("set_maxfiles: getrlimit (2) for RLIMIT_NOFILE failed with error %s\n", strerror(errno) )); /* just guess... */ - return requested_max; + return saved_current_limit; } +#if defined(RLIM_INFINITY) + if(rlp.rlim_cur == RLIM_INFINITY) + return saved_current_limit; +#endif + + if((int)rlp.rlim_cur > saved_current_limit) + return saved_current_limit; + return rlp.rlim_cur; -#else +#else /* !defined(HAVE_GETRLIMIT) || !defined(RLIMIT_NOFILE) */ /* * No way to know - just guess... */ |