summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2002-10-22 22:17:06 +0000
committerJeremy Allison <jra@samba.org>2002-10-22 22:17:06 +0000
commit9b323a3c0deb73cea3c39e5b7323bdf17e199c5c (patch)
treedd3e4eb54dda18ebf76e84134955f606de2f1482
parentc166b812a9d1733a8aec896884c37c6bdc73f070 (diff)
downloadsamba-9b323a3c0deb73cea3c39e5b7323bdf17e199c5c.tar.gz
samba-9b323a3c0deb73cea3c39e5b7323bdf17e199c5c.tar.bz2
samba-9b323a3c0deb73cea3c39e5b7323bdf17e199c5c.zip
Fix for systems that allow more than 65536 open files per process.
Jeremy. (This used to be commit ff537f10a0c0b6b1d9055eb776d1e8a9864e8363)
-rw-r--r--source3/include/local.h3
-rw-r--r--source3/rpc_server/srv_pipe_hnd.c4
-rw-r--r--source3/smbd/files.c9
3 files changed, 11 insertions, 5 deletions
diff --git a/source3/include/local.h b/source3/include/local.h
index 2be9c1e101..20fa5ff52a 100644
--- a/source3/include/local.h
+++ b/source3/include/local.h
@@ -213,4 +213,7 @@
/* Max number of jobs per print queue. */
#define PRINT_MAX_JOBID 10000
+/* Max number of open RPC pipes. */
+#define MAX_OPEN_PIPES 2048
+
#endif
diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c
index cc6e4b95f9..1695419687 100644
--- a/source3/rpc_server/srv_pipe_hnd.c
+++ b/source3/rpc_server/srv_pipe_hnd.c
@@ -31,10 +31,6 @@
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
diff --git a/source3/smbd/files.c b/source3/smbd/files.c
index c055fb54eb..d926718c5d 100644
--- a/source3/smbd/files.c
+++ b/source3/smbd/files.c
@@ -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) {