From 93bbfce02b4ad3f51cef9b057a3959f4e091529f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 5 Oct 1998 01:57:03 +0000 Subject: added a function set_maxfiles() to set our file rlimit to the max possible and return the max. (This used to be commit 7a7b5ee1689b6be57752d176c7b77a2f1b453486) --- source3/lib/util.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'source3/lib/util.c') diff --git a/source3/lib/util.c b/source3/lib/util.c index 38cde624d4..d079f86988 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -4845,3 +4845,26 @@ void zero_free(void *p, size_t size) free(p); } + +/***************************************************************** +set our open file limit to the max and return the limit +*****************************************************************/ +int set_maxfiles(void) +{ +#if (defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE)) + struct rlimit rlp; + getrlimit(RLIMIT_NOFILE, &rlp); + /* 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 = rlp.rlim_max; + setrlimit(RLIMIT_NOFILE, &rlp); + getrlimit(RLIMIT_NOFILE, &rlp); + return rlp.rlim_cur; +#else + /* just guess ... */ + return 1024; +#endif +} + -- cgit