summaryrefslogtreecommitdiff
path: root/source3/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
commit4aa44f7475e03dcc596f6a13fffffda7268074a1 (patch)
tree2b0529c892a64a3c2283df64d6ea14433056d04a /source3/smbd/connection.c
parentdcc2fe7cb61937aa191bf8b5f353d0308a8011a3 (diff)
downloadsamba-4aa44f7475e03dcc596f6a13fffffda7268074a1.tar.gz
samba-4aa44f7475e03dcc596f6a13fffffda7268074a1.tar.bz2
samba-4aa44f7475e03dcc596f6a13fffffda7268074a1.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 (This used to be commit e43e94cda1ad8876b3cb5d1129080b57fa6ec214)
Diffstat (limited to 'source3/smbd/connection.c')
-rw-r--r--source3/smbd/connection.c29
1 files changed, 8 insertions, 21 deletions
diff --git a/source3/smbd/connection.c b/source3/smbd/connection.c
index e609b90a50..b9cdede69e 100644
--- a/source3/smbd/connection.c
+++ b/source3/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;
}