summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/lib/util.c24
-rw-r--r--source3/smbd/files.c6
2 files changed, 27 insertions, 3 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)) {
diff --git a/source3/smbd/files.c b/source3/smbd/files.c
index a4837a1a8b..33243e1e94 100644
--- a/source3/smbd/files.c
+++ b/source3/smbd/files.c
@@ -134,7 +134,7 @@ initialise file structures
void file_init(void)
{
- int request_max_open_files = lp_max_open_files();
+ int request_max_open_files = lp_max_open_files();
int real_lim;
/*
@@ -146,8 +146,8 @@ void file_init(void)
real_max_open_files = real_lim - MAX_OPEN_FUDGEFACTOR;
- if(real_max_open_files != request_max_open_files) {
- DEBUG(1,("file_init: Information only: requested %d \
+ if(real_max_open_files != request_max_open_files) {
+ DEBUG(1,("file_init: Information only: requested %d \
open files, %d are available.\n", request_max_open_files, real_max_open_files));
}