summaryrefslogtreecommitdiff
path: root/source3/smbd/files.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
commit93bbfce02b4ad3f51cef9b057a3959f4e091529f (patch)
tree74ac879bfe6692191144101a5683da539c539ce9 /source3/smbd/files.c
parent0531f4640a7a0154e35af8146ed46e47c5742574 (diff)
downloadsamba-93bbfce02b4ad3f51cef9b057a3959f4e091529f.tar.gz
samba-93bbfce02b4ad3f51cef9b057a3959f4e091529f.tar.bz2
samba-93bbfce02b4ad3f51cef9b057a3959f4e091529f.zip
added a function set_maxfiles() to set our file rlimit to the max
possible and return the max. (This used to be commit 7a7b5ee1689b6be57752d176c7b77a2f1b453486)
Diffstat (limited to 'source3/smbd/files.c')
-rw-r--r--source3/smbd/files.c35
1 files changed, 8 insertions, 27 deletions
diff --git a/source3/smbd/files.c b/source3/smbd/files.c
index 4000439db0..6afa059753 100644
--- a/source3/smbd/files.c
+++ b/source3/smbd/files.c
@@ -202,38 +202,19 @@ initialise file structures
void file_init(void)
{
- real_max_open_files = lp_max_open_files();
-
-#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 = (real_max_open_files+MAX_OPEN_FUDGEFACTOR>rlp.rlim_max)?
- rlp.rlim_max:real_max_open_files+MAX_OPEN_FUDGEFACTOR;
- setrlimit(RLIMIT_NOFILE, &rlp);
- getrlimit(RLIMIT_NOFILE, &rlp);
- if(rlp.rlim_cur != (real_max_open_files + MAX_OPEN_FUDGEFACTOR))
- DEBUG(0,("file_init: Maximum number of open files requested per session \
-was %d, actual files available per session = %d\n",
- real_max_open_files, (int)rlp.rlim_cur - MAX_OPEN_FUDGEFACTOR ));
-
- DEBUG(2,("Maximum number of open files per session is %d\n",
- (int)rlp.rlim_cur - MAX_OPEN_FUDGEFACTOR));
-
- real_max_open_files = (int)rlp.rlim_cur - MAX_OPEN_FUDGEFACTOR;
- }
-#endif
+ int real_max_open_files, lim;
- file_bmap = bitmap_allocate(real_max_open_files);
+ lim = set_maxfiles();
+ lim = MIN(lim, lp_max_open_files());
+ real_max_open_files = lim - MAX_OPEN_FUDGEFACTOR;
+
+ file_bmap = bitmap_allocate(real_max_open_files);
+
if (!file_bmap) {
exit_server("out of memory in file_init");
}
-
+
/*
* Ensure that pipe_handle_oppset is set correctly.
*/