Fix bug #6837 - "Too many open files" when trying to access large number of files
authorJeremy Allison <jra@samba.org>
Wed, 2 Dec 2009 18:01:14 +0000 (10:01 -0800)
committerJeremy Allison <jra@samba.org>
Wed, 2 Dec 2009 18:01:14 +0000 (10:01 -0800)
from Windows 7. Original patch by me fixed up with the correct open files number
by jmaggard10@hotmail.com.
Jeremy.

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

index 45767ad1c150dfffe99853ebbfc19e55d4038127..de54ea5886613a0cea46d2c30b1bfb13318f13c2 100644 (file)
 #ifndef MAX_OPEN_FILES
 #define MAX_OPEN_FILES 10000
 #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 1050
+#endif
+
 #define WORDMAX 0xFFFF
 
 /* the maximum password length before we declare a likely attack */
index a1f5328763416ca26ac95c5735b8bcfbd294ffed..3d426ecf3bf9714d83b95c20c67d517b4cf90a4e 100644 (file)
@@ -4739,6 +4739,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 2bc5ba6816e0a75ed431c6239652c765364ab654..455666f8df71b4313cbcb4341415f751e7cf32e1 100644 (file)
@@ -171,8 +171,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();