s3:dbwrap_watch: let dbwrap_watched_delete() call dbwrap_watched_record_storev(num_db...
authorStefan Metzmacher <metze@samba.org>
Sun, 26 Jun 2022 12:57:06 +0000 (12:57 +0000)
committerRalph Boehme <slow@samba.org>
Tue, 26 Jul 2022 13:40:34 +0000 (13:40 +0000)
dbwrap_watched_record_storev() will handle the high level storev and
delete, it will find out if we can remove the record as there's no value
and also no watchers to be stored.

This is no real change for now as dbwrap_watched_record_wakeup() will
always exits with wrec->watchers.count = 0, but that will change in the next
commits.

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>
source3/lib/dbwrap/dbwrap_watch.c

index 20d08b55fc8c9f2a100794e9054d82c3265a136d..12d1f3e92ebe2b32f6d9ded0fab0ac78f2a24df6 100644 (file)
@@ -200,8 +200,6 @@ static struct db_watched_record *db_record_get_watched_record(struct db_record *
 static NTSTATUS dbwrap_watched_record_storev(
        struct db_watched_record *wrec,
        const TDB_DATA *dbufs, int num_dbufs, int flags);
-static NTSTATUS dbwrap_watched_record_delete(
-       struct db_watched_record *wrec);
 static NTSTATUS dbwrap_watched_storev(struct db_record *rec,
                                      const TDB_DATA *dbufs, int num_dbufs,
                                      int flags);
@@ -550,22 +548,16 @@ static NTSTATUS dbwrap_watched_storev(struct db_record *rec,
        return dbwrap_watched_record_storev(wrec, dbufs, num_dbufs, flags);
 }
 
-static NTSTATUS dbwrap_watched_record_delete(
-       struct db_watched_record *wrec)
-{
-       dbwrap_watched_record_wakeup(wrec);
-
-       /*
-        * Watchers were informed, we can throw away the record now
-        */
-       return dbwrap_record_delete(wrec->backend.rec);
-}
-
 static NTSTATUS dbwrap_watched_delete(struct db_record *rec)
 {
        struct db_watched_record *wrec = db_record_get_watched_record(rec);
 
-       return dbwrap_watched_record_delete(wrec);
+       /*
+        * dbwrap_watched_record_storev() will figure out
+        * if the record should be deleted or if there are still
+        * watchers to be stored.
+        */
+       return dbwrap_watched_record_storev(wrec, NULL, 0, 0);
 }
 
 struct dbwrap_watched_traverse_state {