summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2022-06-26 10:58:21 +0200
committerRalph Boehme <slow@samba.org>2022-07-26 13:40:34 +0000
commit726f468ccdb432c35dadef1aa4af6a041cbf46f2 (patch)
tree8c5f0c41373d6dda6e41f8b46eb31aa35cdef15f
parenteb89748ee4a9c58da8064b41d0253e00c30c213f (diff)
downloadsamba-726f468ccdb432c35dadef1aa4af6a041cbf46f2.tar.gz
s3:dbwrap_watch: split out db_watched_record_fini() from db_watched_record_destructor()
That makes it easier to understand that db_watched_record_init() and db_watched_record_fini() wrap any caller activity on the record, either during do_locked or between fetch_locked and the related destructor. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
-rw-r--r--source3/lib/dbwrap/dbwrap_watch.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/source3/lib/dbwrap/dbwrap_watch.c b/source3/lib/dbwrap/dbwrap_watch.c
index 4ad09b3543e..bad34686f11 100644
--- a/source3/lib/dbwrap/dbwrap_watch.c
+++ b/source3/lib/dbwrap/dbwrap_watch.c
@@ -324,7 +324,7 @@ static void dbwrap_watched_add_watcher(
state->status = dbwrap_record_storev(rec, dbufs, ARRAY_SIZE(dbufs), 0);
}
-static int db_watched_record_destructor(struct db_watched_record *wrec)
+static void db_watched_record_fini(struct db_watched_record *wrec)
{
struct dbwrap_watched_add_watcher_state state = { .w = wrec->added };
struct db_context *backend = dbwrap_record_get_db(wrec->backend.rec);
@@ -332,7 +332,7 @@ static int db_watched_record_destructor(struct db_watched_record *wrec)
NTSTATUS status;
if (wrec->added.pid.pid == 0) {
- return 0;
+ return;
}
status = dbwrap_do_locked(
@@ -340,13 +340,20 @@ static int db_watched_record_destructor(struct db_watched_record *wrec)
if (!NT_STATUS_IS_OK(status)) {
DBG_WARNING("dbwrap_do_locked failed: %s\n",
nt_errstr(status));
- return 0;
+ return;
}
if (!NT_STATUS_IS_OK(state.status)) {
DBG_WARNING("dbwrap_watched_add_watcher failed: %s\n",
nt_errstr(state.status));
- return 0;
+ return;
}
+
+ return;
+}
+
+static int db_watched_record_destructor(struct db_watched_record *wrec)
+{
+ db_watched_record_fini(wrec);
return 0;
}
@@ -386,7 +393,7 @@ static void dbwrap_watched_do_locked_fn(
state->fn(&rec, rec.value, state->private_data);
- db_watched_record_destructor(&wrec);
+ db_watched_record_fini(&wrec);
}
static NTSTATUS dbwrap_watched_do_locked(struct db_context *db, TDB_DATA key,