summaryrefslogtreecommitdiffstats
path: root/source/lib/util.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>1998-10-05 01:57:03 +0000
committerAndrew Tridgell <tridge@samba.org>1998-10-05 01:57:03 +0000
commit7a7b5ee1689b6be57752d176c7b77a2f1b453486 (patch)
tree33d6c2280d2a57389ab5db4d713b08fda514367f /source/lib/util.c
parent6a1b346d98c10688f0995a6ab8fd155a77ead258 (diff)
downloadsamba-7a7b5ee1689b6be57752d176c7b77a2f1b453486.tar.gz
samba-7a7b5ee1689b6be57752d176c7b77a2f1b453486.tar.xz
samba-7a7b5ee1689b6be57752d176c7b77a2f1b453486.zip
added a function set_maxfiles() to set our file rlimit to the max
possible and return the max.
Diffstat (limited to 'source/lib/util.c')
-rw-r--r--source/lib/util.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/source/lib/util.c b/source/lib/util.c
index 38cde624d4f..d079f869882 100644
--- a/source/lib/util.c
+++ b/source/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
+}
+