From 726f468ccdb432c35dadef1aa4af6a041cbf46f2 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 26 Jun 2022 10:58:21 +0200 Subject: [PATCH] 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 Reviewed-by: Jeremy Allison Reviewed-by: Ralph Boehme --- source3/lib/dbwrap/dbwrap_watch.c | 17 ++++++++++++----- 1 file 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, -- 2.47.3