summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
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);
}
}