Fix for systems that allow more than 65536 open files per process.
authorJeremy Allison <jra@samba.org>
Tue, 22 Oct 2002 22:17:29 +0000 (22:17 +0000)
committerJeremy Allison <jra@samba.org>
Tue, 22 Oct 2002 22:17:29 +0000 (22:17 +0000)
Jeremy.
(This used to be commit 947a56ce00e552e8b8d2ed64435eabde6225f044)

source3/include/local.h
source3/rpc_server/srv_pipe_hnd.c
source3/smbd/files.c

index 2be9c1e1017409f5e907097cd6dabd23bd7ab485..20fa5ff52a4ed83a72e3c8d2991c51a46c9acb94 100644 (file)
 /* Max number of jobs per print queue. */
 #define PRINT_MAX_JOBID 10000
 
+/* Max number of open RPC pipes. */
+#define MAX_OPEN_PIPES 2048
+
 #endif
index cc6e4b95f9ee6cde102c609bdb0fca4a4a6a4bd6..1695419687872ff4b9a9a7f19d1d3541c76ab636 100644 (file)
 static smb_np_struct *chain_p;
 static int pipes_open;
 
-#ifndef MAX_OPEN_PIPES
-#define MAX_OPEN_PIPES 2048
-#endif
-
 /*
  * Sometimes I can't decide if I hate Windows printer driver
  * writers more than I hate the Windows spooler service driver
index c055fb54eb4808e8957cef5c218c9540ab50ba95..d926718c5d326581923929a6b62cb6ee09ec3b17 100644 (file)
@@ -112,6 +112,8 @@ files_struct *file_new(connection_struct *conn)
        files_used++;
 
        fsp->fnum = i + FILE_HANDLE_OFFSET;
+       SMB_ASSERT(fsp->fnum < 65536);
+
        string_set(&fsp->fsp_name,"");
        
        DLIST_ADD(Files, fsp);
@@ -144,7 +146,7 @@ void file_close_conn(connection_struct *conn)
  Initialise file structures.
 ****************************************************************************/
 
-#define MAX_OPEN_FUDGEFACTOR 10
+#define MAX_OPEN_FUDGEFACTOR 20
 
 void file_init(void)
 {
@@ -160,11 +162,16 @@ void file_init(void)
 
        real_max_open_files = real_lim - MAX_OPEN_FUDGEFACTOR;
 
+       if (real_max_open_files + FILE_HANDLE_OFFSET + MAX_OPEN_PIPES > 65536)
+               real_max_open_files = 65536 - FILE_HANDLE_OFFSET - MAX_OPEN_PIPES;
+
        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));
        }
 
+       SMB_ASSERT(real_max_open_files > 100);
+
        file_bmap = bitmap_allocate(real_max_open_files);
        
        if (!file_bmap) {