diff options
author | Jeremy Allison <jra@samba.org> | 2004-02-19 01:55:24 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2004-02-19 01:55:24 +0000 |
commit | 14dee038019b11300466b148c53515fc76e5e870 (patch) | |
tree | da3709e7115af50b7c08de0a0409002817b09e01 /source/smbd/session.c | |
parent | ad1ebb5000066d44ce94f0341fb31351b3900e95 (diff) | |
download | samba-14dee038019b11300466b148c53515fc76e5e870.tar.gz samba-14dee038019b11300466b148c53515fc76e5e870.tar.xz samba-14dee038019b11300466b148c53515fc76e5e870.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.
Diffstat (limited to 'source/smbd/session.c')
-rw-r--r-- | source/smbd/session.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/source/smbd/session.c b/source/smbd/session.c index a811a6e305a..61118f13dd9 100644 --- a/source/smbd/session.c +++ b/source/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; } - |