summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2004-02-19 01:55:24 +0000
committerJeremy Allison <jra@samba.org>2004-02-19 01:55:24 +0000
commit8eec62ebfb238133d95d7247b7126292f47c7093 (patch)
tree5d3894f97ced64d8e2753603a2ea25897d831c51 /source3/smbd
parent5e39e9f3130e48917db9d9802623befa536df399 (diff)
downloadsamba-8eec62ebfb238133d95d7247b7126292f47c7093.tar.gz
samba-8eec62ebfb238133d95d7247b7126292f47c7093.tar.bz2
samba-8eec62ebfb238133d95d7247b7126292f47c7093.zip
Fix the "too many fcntl locks" scalability problem raised by tridge.
I've now tested this in daemon mode and also on xinetd and I'm pretty sure it's working. Jeremy. (This used to be commit 14dee038019b11300466b148c53515fc76e5e870)
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/server.c34
-rw-r--r--source3/smbd/session.c29
2 files changed, 39 insertions, 24 deletions
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index be59e92cd7..1de33739b2 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -405,10 +405,10 @@ static BOOL open_sockets_smbd(BOOL is_daemon, BOOL interactive, const char *smb_
done correctly in the process. */
reset_globals_after_fork();
- /* tdb needs special fork handling */
+ /* tdb needs special fork handling - remove CLEAR_IF_FIRST flags */
if (tdb_reopen_all() == -1) {
DEBUG(0,("tdb_reopen_all failed.\n"));
- return False;
+ smb_panic("tdb_reopen_all failed.");
}
return True;
@@ -809,9 +809,27 @@ void build_options(BOOL screen);
if (is_daemon)
pidfile_create("smbd");
+ /* Setup all the TDB's - including CLEAR_IF_FIRST tdb's. */
if (!message_init())
exit(1);
+ if (!session_init())
+ exit(1);
+
+ if (conn_tdb_ctx() == NULL)
+ exit(1);
+
+ if (!locking_init(0))
+ exit(1);
+
+ if (!share_info_db_init())
+ exit(1);
+
+ namecache_enable();
+
+ if (!init_registry())
+ exit(1);
+
if (!print_backend_init())
exit(1);
@@ -832,17 +850,6 @@ void build_options(BOOL screen);
* everything after this point is run after the fork()
*/
- namecache_enable();
-
- if (!locking_init(0))
- exit(1);
-
- if (!share_info_db_init())
- exit(1);
-
- if (!init_registry())
- exit(1);
-
/* Initialise the password backed before the global_sam_sid
to ensure that we fetch from ldap before we make a domain sid up */
@@ -891,4 +898,3 @@ void build_options(BOOL screen);
exit_server("normal exit");
return(0);
}
-
diff --git a/source3/smbd/session.c b/source3/smbd/session.c
index a811a6e305..61118f13dd 100644
--- a/source3/smbd/session.c
+++ b/source3/smbd/session.c
@@ -28,6 +28,22 @@
#include "includes.h"
static TDB_CONTEXT *tdb;
+
+BOOL session_init(void)
+{
+ if (tdb)
+ return True;
+
+ tdb = tdb_open_ex(lock_path("sessionid.tdb"), 0, TDB_CLEAR_IF_FIRST|TDB_DEFAULT,
+ O_RDWR | O_CREAT, 0644, smbd_tdb_log);
+ if (!tdb) {
+ DEBUG(1,("session_init: failed to open sessionid tdb\n"));
+ return False;
+ }
+
+ return True;
+}
+
/* called when a session is created */
BOOL session_claim(user_struct *vuser)
{
@@ -52,14 +68,8 @@ BOOL session_claim(user_struct *vuser)
return True;
}
- if (!tdb) {
- tdb = tdb_open_ex(lock_path("sessionid.tdb"), 0, TDB_CLEAR_IF_FIRST|TDB_DEFAULT,
- O_RDWR | O_CREAT, 0644, smbd_tdb_log);
- if (!tdb) {
- DEBUG(1,("session_claim: failed to open sessionid tdb\n"));
- return False;
- }
- }
+ if (!session_init())
+ return False;
ZERO_STRUCT(sessionid);
@@ -190,7 +200,7 @@ void session_yield(user_struct *vuser)
static BOOL session_traverse(int (*fn)(TDB_CONTEXT *, TDB_DATA, TDB_DATA, void *), void *state)
{
- if (!tdb) {
+ if (!session_init()) {
DEBUG(3, ("No tdb opened\n"));
return False;
}
@@ -238,4 +248,3 @@ int list_sessions(struct sessionid **session_list)
*session_list = sesslist.sessions;
return sesslist.count;
}
-