diff options
author | Stefan Metzmacher <metze@samba.org> | 2012-05-24 12:20:30 +0200 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2012-05-24 18:16:37 +0200 |
commit | 9e45885fcc54fa16e947b5b6370f171c2c7bfaf2 (patch) | |
tree | f2395bc853a8a7764181c364b1c7fe8afbdb9589 /source3/smbd | |
parent | 48e62f2d46a39b09ac0bcad84493b12381bb5a05 (diff) | |
download | samba-9e45885fcc54fa16e947b5b6370f171c2c7bfaf2.tar.gz samba-9e45885fcc54fa16e947b5b6370f171c2c7bfaf2.tar.bz2 samba-9e45885fcc54fa16e947b5b6370f171c2c7bfaf2.zip |
s3:smbd/files: split file_init_global() out of file_init()
metze
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( |