From 8eec62ebfb238133d95d7247b7126292f47c7093 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 19 Feb 2004 01:55:24 +0000 Subject: 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) --- source3/smbd/session.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'source3/smbd/session.c') 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; } - -- cgit