diff options
Diffstat (limited to 'source3/smbd')
-rw-r--r-- | source3/smbd/files.c | 47 | ||||
-rw-r--r-- | source3/smbd/proto.h | 1 |
2 files changed, 35 insertions, 13 deletions
diff --git a/source3/smbd/files.c b/source3/smbd/files.c index ae34006039..fcdd740290 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -189,38 +189,59 @@ void file_close_pid(struct smbd_server_connection *sconn, uint16 smbpid, Initialise file structures. ****************************************************************************/ -bool file_init(struct smbd_server_connection *sconn) +static int files_max_open_fds; + +bool file_init_global(void) { - int request_max_open_files = lp_max_open_files(); + int request_max = lp_max_open_files(); int real_lim; + int real_max; + + if (files_max_open_fds != 0) { + return true; + } /* * Set the max_open files to be the requested * max plus a fudgefactor to allow for the extra * fd's we need such as log files etc... */ - real_lim = set_maxfiles(request_max_open_files + MAX_OPEN_FUDGEFACTOR); + real_lim = set_maxfiles(request_max + MAX_OPEN_FUDGEFACTOR); - sconn->real_max_open_files = real_lim - MAX_OPEN_FUDGEFACTOR; + real_max = real_lim - MAX_OPEN_FUDGEFACTOR; - if (sconn->real_max_open_files + FILE_HANDLE_OFFSET + MAX_OPEN_PIPES - > 65536) - sconn->real_max_open_files = - 65536 - FILE_HANDLE_OFFSET - MAX_OPEN_PIPES; + if (real_max + FILE_HANDLE_OFFSET + MAX_OPEN_PIPES > 65536) { + real_max = 65536 - FILE_HANDLE_OFFSET - MAX_OPEN_PIPES; + } - if(sconn->real_max_open_files != request_max_open_files) { - DEBUG(1, ("file_init: Information only: requested %d " + if (real_max != request_max) { + DEBUG(1, ("file_init_global: Information only: requested %d " "open files, %d are available.\n", - request_max_open_files, sconn->real_max_open_files)); + request_max, real_max)); } - SMB_ASSERT(sconn->real_max_open_files > 100); + SMB_ASSERT(real_max > 100); - sconn->file_bmap = bitmap_talloc(sconn, sconn->real_max_open_files); + files_max_open_fds = real_max; + return true; +} +bool file_init(struct smbd_server_connection *sconn) +{ + bool ok; + + ok = file_init_global(); + if (!ok) { + return false; + } + + sconn->real_max_open_files = files_max_open_fds; + + sconn->file_bmap = bitmap_talloc(sconn, sconn->real_max_open_files); if (!sconn->file_bmap) { return false; } + return true; } diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 60f9a7d767..30eed73f8d 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -369,6 +369,7 @@ NTSTATUS file_new(struct smb_request *req, connection_struct *conn, void file_close_conn(connection_struct *conn); void file_close_pid(struct smbd_server_connection *sconn, uint16 smbpid, int vuid); +bool file_init_global(void); bool file_init(struct smbd_server_connection *sconn); void file_close_user(struct smbd_server_connection *sconn, int vuid); struct files_struct *files_forall( |