diff options
author | Jeremy Allison <jra@samba.org> | 2001-04-13 19:33:26 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2001-04-13 19:33:26 +0000 |
commit | 3c2c047e822b6c74ecc176d1623d5292657cde62 (patch) | |
tree | c82533d0a99a0728ae583c6909581757c03f89e7 /source3/lib | |
parent | 2ef68c7e92d4661664f0410509f7cb551e74a198 (diff) | |
download | samba-3c2c047e822b6c74ecc176d1623d5292657cde62.tar.gz samba-3c2c047e822b6c74ecc176d1623d5292657cde62.tar.bz2 samba-3c2c047e822b6c74ecc176d1623d5292657cde62.zip |
Added fix from "Eric Boehm" <boehm@nortelnetworks.com> to try and set hard
limit before setting soft limit.
Jeremy.
(This used to be commit a1eb2752a8bee9cc7d92c664c3de84e02620933d)
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/util.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c index 506a0334d1..3dd7fad8fc 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -1636,6 +1636,30 @@ int set_maxfiles(int requested_max) * which always returns RLIM_INFINITY for rlp.rlim_max. */ + /* Try raising the hard (max) limit to the requested amount. */ + +#if defined(RLIM_INFINITY) + if (rlp.rlim_max != RLIM_INFINITY) { + int orig_max = rlp.rlim_max; + + if ( rlp.rlim_max < requested_max ) + rlp.rlim_max = requested_max; + + /* This failing is not an error - many systems (Linux) don't + support our default request of 10,000 open files. JRA. */ + + if(setrlimit(RLIMIT_NOFILE, &rlp)) { + DEBUG(3,("set_maxfiles: setrlimit for RLIMIT_NOFILE for %d max files failed with error %s\n", + (int)rlp.rlim_max, strerror(errno) )); + + /* Set failed - restore original value from get. */ + rlp.rlim_max = orig_max; + } + } +#endif + + /* Now try setting the soft (current) limit. */ + saved_current_limit = rlp.rlim_cur = MIN(requested_max,rlp.rlim_max); if(setrlimit(RLIMIT_NOFILE, &rlp)) { |