diff options
author | Andrew Tridgell <tridge@samba.org> | 2000-01-02 23:00:27 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2000-01-02 23:00:27 +0000 |
commit | 9a781a8c6de9513ba5f4cafef41379fae96807c1 (patch) | |
tree | d9bd28fba6ccdaabe43d2183200310cb6bc4d283 /source3/smbd | |
parent | 321983bb6b68b5fe18f1021dc5851ce3bb0de625 (diff) | |
download | samba-9a781a8c6de9513ba5f4cafef41379fae96807c1.tar.gz samba-9a781a8c6de9513ba5f4cafef41379fae96807c1.tar.bz2 samba-9a781a8c6de9513ba5f4cafef41379fae96807c1.zip |
- added tdb_flags option to tdb_open()
- added TDB_CLEAR_IF_FIRST flag to clear the database if this is the
first attached process. Useful for non-persistent databases like our
locking area (this will also make upgrades to new database layouts easier)
- use lock_path() in a couple of places
- leave connections database open while smbd running
- cleaned up some tdb code a little, using macros for constants
(This used to be commit 00e9da3ca577527db392aced62f02c69cfee8f4f)
Diffstat (limited to 'source3/smbd')
-rw-r--r-- | source3/smbd/connection.c | 28 |
1 files changed, 6 insertions, 22 deletions
diff --git a/source3/smbd/connection.c b/source3/smbd/connection.c index 5b5ab005c8..13c051a5a3 100644 --- a/source3/smbd/connection.c +++ b/source3/smbd/connection.c @@ -23,6 +23,7 @@ extern fstring remote_machine; +static TDB_CONTEXT *tdb; extern int DEBUGLEVEL; @@ -33,9 +34,7 @@ BOOL yield_connection(connection_struct *conn,char *name,int max_connections) { struct connections_key key; TDB_DATA kbuf; - TDB_CONTEXT *tdb; - tdb = tdb_open(lock_path("connections.tdb"), 0, O_RDWR | O_CREAT, 0644); if (!tdb) return False; DEBUG(3,("Yielding connection to %s\n",name)); @@ -49,7 +48,6 @@ BOOL yield_connection(connection_struct *conn,char *name,int max_connections) kbuf.dsize = sizeof(key); tdb_delete(tdb, kbuf); - tdb_close(tdb); return(True); } @@ -57,30 +55,20 @@ BOOL yield_connection(connection_struct *conn,char *name,int max_connections) /**************************************************************************** claim an entry in the connections database ****************************************************************************/ -int delete_dead(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf) -{ - struct connections_key key; - memcpy(&key, kbuf.dptr, sizeof(key)); - if (!process_exists(key.pid)) tdb_delete(tdb, kbuf); - return 0; -} - - -/**************************************************************************** -claim an entry in the connections database -****************************************************************************/ BOOL claim_connection(connection_struct *conn,char *name,int max_connections,BOOL Clear) { struct connections_key key; struct connections_data crec; TDB_DATA kbuf, dbuf; - TDB_CONTEXT *tdb; extern int Client; if (max_connections <= 0) return(True); - - tdb = tdb_open(lock_path("connections.tdb"), 0, O_RDWR | O_CREAT, 0644); + + if (!tdb) { + tdb = tdb_open(lock_path("connections.tdb"), 0, TDB_CLEAR_IF_FIRST, + O_RDWR | O_CREAT, 0644); + } if (!tdb) return False; DEBUG(5,("claiming %s %d\n",name,max_connections)); @@ -93,10 +81,6 @@ BOOL claim_connection(connection_struct *conn,char *name,int max_connections,BOO kbuf.dptr = (char *)&key; kbuf.dsize = sizeof(key); - if (Clear) { - tdb_traverse(tdb, delete_dead); - } - /* fill in the crec */ ZERO_STRUCT(crec); crec.magic = 0x280267; |