summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2001-09-19 07:06:34 +0000
committerJeremy Allison <jra@samba.org>2001-09-19 07:06:34 +0000
commit79a9902d39859e0b0dc9d375ffc7714faf00bbb1 (patch)
treed5172df1ca68946d9d7bfdb58657e9d07d76b065 /source3/smbd
parent0ef1acbabb13006429d06cb1d90bf887bf987ddc (diff)
downloadsamba-79a9902d39859e0b0dc9d375ffc7714faf00bbb1.tar.gz
samba-79a9902d39859e0b0dc9d375ffc7714faf00bbb1.tar.bz2
samba-79a9902d39859e0b0dc9d375ffc7714faf00bbb1.zip
Removed unneeded variable, added comment on deadlock prevention.
Jeremy. (This used to be commit 3f52632ac9c45c66613c3a2fd41f1ba73ca3fefc)
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/connection.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/source3/smbd/connection.c b/source3/smbd/connection.c
index 0f0697b1c7..e1b2bc071a 100644
--- a/source3/smbd/connection.c
+++ b/source3/smbd/connection.c
@@ -115,7 +115,6 @@ BOOL claim_connection(connection_struct *conn,char *name,int max_connections,BOO
struct connections_key key;
struct connections_data crec;
TDB_DATA kbuf, dbuf;
- BOOL ret = True;
if (!tdb) {
tdb = tdb_open_log(lock_path("connections.tdb"), 0, TDB_CLEAR_IF_FIRST|TDB_DEFAULT,
@@ -136,18 +135,21 @@ BOOL claim_connection(connection_struct *conn,char *name,int max_connections,BOO
cs.name = lp_servicename(SNUM(conn));
cs.Clear = Clear;
+ /*
+ * This has a race condition, but locking the chain before hand is worse
+ * as it leads to deadlock.
+ */
+
if (tdb_traverse(tdb, count_fn, &cs) == -1) {
DEBUG(0,("claim_connection: traverse of connections.tdb failed with error %s.\n",
tdb_errorstr(tdb) ));
- ret = False;
- goto out;
+ return False;
}
if (cs.curr_connections >= max_connections) {
DEBUG(1,("claim_connection: Max connections (%d) exceeded for %s\n",
max_connections, name ));
- ret = False;
- goto out;
+ return False;
}
}
@@ -183,10 +185,8 @@ BOOL claim_connection(connection_struct *conn,char *name,int max_connections,BOO
if (tdb_store(tdb, kbuf, dbuf, TDB_REPLACE) != 0) {
DEBUG(0,("claim_connection: tdb_store failed with error %s.\n",
tdb_errorstr(tdb) ));
- ret = False;
+ return False;
}
- out:
-
- return ret;
+ return True;
}