summaryrefslogtreecommitdiffstats
path: root/source/smbd/connection.c
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2007-05-08 13:44:36 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:21:55 -0500
commite43e94cda1ad8876b3cb5d1129080b57fa6ec214 (patch)
tree071df662605161a0ed7b26700f555d129f2b5c66 /source/smbd/connection.c
parent86c510e3198e03ed6efa61b27530bbb008f6802b (diff)
downloadsamba-e43e94cda1ad8876b3cb5d1129080b57fa6ec214.tar.gz
samba-e43e94cda1ad8876b3cb5d1129080b57fa6ec214.tar.xz
samba-e43e94cda1ad8876b3cb5d1129080b57fa6ec214.zip
r22761: This introduces lib/conn_tdb.c with two main functions: connections_traverse
and connections_forall. This centralizes all the routines that did individual tdb_open("connections.tdb") and direct tdb_traverse. Volker
Diffstat (limited to 'source/smbd/connection.c')
-rw-r--r--source/smbd/connection.c29
1 files changed, 8 insertions, 21 deletions
diff --git a/source/smbd/connection.c b/source/smbd/connection.c
index e609b90a507..b9cdede69ed 100644
--- a/source/smbd/connection.c
+++ b/source/smbd/connection.c
@@ -20,21 +20,6 @@
#include "includes.h"
-static TDB_CONTEXT *tdb;
-
-/****************************************************************************
- Return the connection tdb context (used for message send all).
-****************************************************************************/
-
-TDB_CONTEXT *conn_tdb_ctx(void)
-{
- if (!tdb)
- tdb = tdb_open_log(lock_path("connections.tdb"), 0, TDB_CLEAR_IF_FIRST|TDB_DEFAULT,
- O_RDWR | O_CREAT, 0644);
-
- return tdb;
-}
-
static void make_conn_key(connection_struct *conn, const char *name, TDB_DATA *pkbuf, struct connections_key *pkey)
{
ZERO_STRUCTP(pkey);
@@ -62,6 +47,7 @@ BOOL yield_connection(connection_struct *conn, const char *name)
{
struct connections_key key;
TDB_DATA kbuf;
+ TDB_CONTEXT *tdb = conn_tdb_ctx(True);
if (!tdb)
return False;
@@ -112,7 +98,7 @@ static int count_fn( TDB_CONTEXT *the_tdb, TDB_DATA kbuf, TDB_DATA dbuf, void *u
DEBUG(2,("pid %s doesn't exist - deleting connections %d [%s]\n",
procid_str_static(&crec.pid), crec.cnum, crec.servicename));
if (tdb_delete(the_tdb, kbuf) != 0)
- DEBUG(0,("count_fn: tdb_delete failed with error %s\n", tdb_errorstr(tdb) ));
+ DEBUG(0,("count_fn: tdb_delete failed with error %s\n", tdb_errorstr(the_tdb) ));
return 0;
}
@@ -139,6 +125,7 @@ static int count_fn( TDB_CONTEXT *the_tdb, TDB_DATA kbuf, TDB_DATA dbuf, void *u
int count_current_connections( const char *sharename, BOOL clear )
{
struct count_stat cs;
+ TDB_CONTEXT *tdb = conn_tdb_ctx(True);
cs.mypid = sys_getpid();
cs.curr_connections = 0;
@@ -184,11 +171,10 @@ BOOL claim_connection(connection_struct *conn, const char *name,int max_connecti
struct connections_key key;
struct connections_data crec;
TDB_DATA kbuf, dbuf;
+ TDB_CONTEXT *tdb = conn_tdb_ctx(True);
if (!tdb) {
- if ( (tdb =conn_tdb_ctx()) == NULL ) {
- return False;
- }
+ return False;
}
/*
@@ -245,6 +231,7 @@ BOOL register_message_flags(BOOL doreg, uint32 msg_flags)
struct connections_key key;
struct connections_data *pcrec;
TDB_DATA kbuf, dbuf;
+ TDB_CONTEXT *tdb = conn_tdb_ctx(True);
if (!tdb)
return False;
@@ -344,7 +331,7 @@ BOOL store_pipe_opendb( smb_np_struct *p )
data.dptr = (uint8 *)prec;
data.dsize = sizeof(struct pipe_open_rec);
- if ( (pipe_tdb = conn_tdb_ctx() ) == NULL ) {
+ if ( (pipe_tdb = conn_tdb_ctx(True) ) == NULL ) {
goto done;
}
@@ -375,7 +362,7 @@ BOOL delete_pipe_opendb( smb_np_struct *p )
goto done;
}
- if ( (pipe_tdb = conn_tdb_ctx() ) == NULL ) {
+ if ( (pipe_tdb = conn_tdb_ctx(True) ) == NULL ) {
goto done;
}