Fix bug 6837 - "Too many open files" when trying to access large number of files
authorJeremy Allison <jra@samba.org>
Fri, 18 Dec 2009 00:59:56 +0000 (16:59 -0800)
committerKarolin Seeger <kseeger@samba.org>
Wed, 30 Dec 2009 08:58:57 +0000 (09:58 +0100)
Win7 needs the Windows server open file handle number of 16384 handles.

Jeremy.
(cherry picked from commit bbdc2c017ca5abb35897ab61717b806133e0af0b)

source3/include/local.h
source3/param/loadparm.c
source3/smbd/files.c

index 45767ad1c150dfffe99853ebbfc19e55d4038127..a88b17be137353194e64674829ee78194a5992f9 100644 (file)
 #define SYSLOG_FACILITY LOG_DAEMON
 #endif
 
-/* 
+/*
+ * Fudgefactor required for open tdb's, etc.
+ */
+
+#ifndef MAX_OPEN_FUDGEFACTOR
+#define MAX_OPEN_FUDGEFACTOR 20
+#endif
+
+/*
+ * Minimum number of open files needed for Windows7 to
+ * work correctly. A little conservative but better that
+ * than run out of fd's.
+ */
+
+#ifndef MIN_OPEN_FILES_WINDOWS
+#define MIN_OPEN_FILES_WINDOWS 16384
+#endif
+
+/*
  * Default number of maximum open files per smbd. This is
  * also limited by the maximum available file descriptors
  * per process and can also be set in smb.conf as "max open files"
@@ -64,9 +82,9 @@
  */
 
 #ifndef MAX_OPEN_FILES
-#define MAX_OPEN_FILES 10000
+#define MAX_OPEN_FILES (MIN_OPEN_FILES_WINDOWS + MAX_OPEN_FUDGEFACTOR)
 #endif
+
 #define WORDMAX 0xFFFF
 
 /* the maximum password length before we declare a likely attack */
index cd27fe48752b33dfa5b277b02fe521e3750e4cbe..ccf642d0d4d9607e5dd628b90fe5344fa7e0e184 100644 (file)
@@ -4692,6 +4692,22 @@ static int max_open_files(void)
 #endif
 #endif
 
+       if (sysctl_max < MIN_OPEN_FILES_WINDOWS) {
+               DEBUG(2,("max_open_files: sysctl_max (%d) below "
+                       "minimum Windows limit (%d)\n",
+                       sysctl_max,
+                       MIN_OPEN_FILES_WINDOWS));
+               sysctl_max = MIN_OPEN_FILES_WINDOWS;
+       }
+
+       if (rlimit_max < MIN_OPEN_FILES_WINDOWS) {
+               DEBUG(2,("rlimit_max: rlimit_max (%d) below "
+                       "minimum Windows limit (%d)\n",
+                       rlimit_max,
+                       MIN_OPEN_FILES_WINDOWS));
+               rlimit_max = MIN_OPEN_FILES_WINDOWS;
+       }
+
        return MIN(sysctl_max, rlimit_max);
 }
 
index 6f82686d5339697dbc0346acc566bdd909f5a3e7..03d2f58271380f5b7c489f94bb1695c936567d24 100644 (file)
@@ -155,8 +155,6 @@ void file_close_pid(uint16 smbpid, int vuid)
  Initialise file structures.
 ****************************************************************************/
 
-#define MAX_OPEN_FUDGEFACTOR 20
-
 void file_init(void)
 {
        int request_max_open_files = lp_max_open_files();