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 | 00e9da3ca577527db392aced62f02c69cfee8f4f (patch) | |
tree | 177cd4e8fd76bc9a298f4458e39911d277919f64 /source/smbd/connection.c | |
parent | 88a146ab04d65fc306569044dc00907a374fac51 (diff) | |
download | samba-00e9da3ca577527db392aced62f02c69cfee8f4f.tar.gz samba-00e9da3ca577527db392aced62f02c69cfee8f4f.tar.xz samba-00e9da3ca577527db392aced62f02c69cfee8f4f.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
Diffstat (limited to 'source/smbd/connection.c')
-rw-r--r-- | source/smbd/connection.c | 28 |
1 files changed, 6 insertions, 22 deletions
diff --git a/source/smbd/connection.c b/source/smbd/connection.c index 5b5ab005c80..13c051a5a36 100644 --- a/source/smbd/connection.c +++ b/source/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; |