summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2001-05-25 00:48:28 +0000
committerJeremy Allison <jra@samba.org>2001-05-25 00:48:28 +0000
commit15e66ba37ae56787897e49039e217b5426924829 (patch)
tree7b0c9c15a4e24f2df40691bd4a0fa917344a0216 /source3/smbd
parent9ff6634db923da17b0946141abf3ce7df61a0dab (diff)
downloadsamba-15e66ba37ae56787897e49039e217b5426924829.tar.gz
samba-15e66ba37ae56787897e49039e217b5426924829.tar.bz2
samba-15e66ba37ae56787897e49039e217b5426924829.zip
Added tdb_change_int_atomic() to allow atomic updates of a tdb int value.
Jeremy. (This used to be commit cf5015f15935605cf69078bc15251db61ddc48c7)
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/process.c12
-rw-r--r--source3/smbd/server.c8
2 files changed, 9 insertions, 11 deletions
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index 74c0cbc96f..1f575e2a46 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -781,12 +781,12 @@ static BOOL smbd_process_limit(void)
/* Always add one to the smbd process count, as exit_server() always
* subtracts one.
*/
- tdb_lock_bystring(conn_tdb_ctx(), "INFO/total_smbds");
- total_smbds = tdb_fetch_int(conn_tdb_ctx(), "INFO/total_smbds");
- total_smbds = total_smbds < 0 ? 1 : total_smbds + 1;
- tdb_store_int(conn_tdb_ctx(), "INFO/total_smbds", total_smbds);
- tdb_unlock_bystring(conn_tdb_ctx(), "INFO/total_smbds");
-
+
+ total_smbds = 1; /* In case we need to create the entry. */
+
+ if (tdb_change_int_atomic(conn_tdb_ctx(), "INFO/total_smbds", &total_smbds, 1) == -1)
+ return True;
+
return total_smbds > lp_max_smbd_processes();
}
else
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 6f4f18562e..fcee30d667 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -421,16 +421,14 @@ static BOOL dump_core(void)
/****************************************************************************
update the current smbd process count
****************************************************************************/
+
static void decrement_smbd_process_count(void)
{
int total_smbds;
if (lp_max_smbd_processes()) {
- tdb_lock_bystring(conn_tdb_ctx(), "INFO/total_smbds");
- if ((total_smbds = tdb_fetch_int(conn_tdb_ctx(), "INFO/total_smbds")) > 0)
- tdb_store_int(conn_tdb_ctx(), "INFO/total_smbds", total_smbds - 1);
-
- tdb_unlock_bystring(conn_tdb_ctx(), "INFO/total_smbds");
+ total_smbds = 0;
+ tdb_change_int_atomic(conn_tdb_ctx(), "INFO/total_smbds", &total_smbds, -1);
}
}