]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
dbwrap: Add publically available dbwrap_watch_wakeup()
authorVolker Lendecke <vl@samba.org>
Fri, 24 May 2019 13:00:45 +0000 (15:00 +0200)
committerRalph Boehme <slow@samba.org>
Thu, 4 Jul 2019 14:03:28 +0000 (14:03 +0000)
Without this, to notify watchers you need to actually store data. This
might be a waste of resources. locking.tdb waiters might actually wait
for leases.tdb or brlock.tdb changes, and locking.tdb records can be
large.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/lib/dbwrap/dbwrap_watch.c
source3/lib/dbwrap/dbwrap_watch.h

index 61c713b3b612750b0bca05eb8dc1a79c9620bf96..9bf3d372621bbd6ad186aa10f7a9fec3d7f72ae2 100644 (file)
@@ -739,6 +739,22 @@ static size_t dbwrap_watched_id(struct db_context *db, uint8_t *id,
        return dbwrap_db_id(ctx->backend, id, idlen);
 }
 
+void dbwrap_watched_wakeup(struct db_record *rec)
+{
+       struct db_watched_subrec *subrec = NULL;
+
+       if (rec->storev == dbwrap_watched_do_locked_storev) {
+               struct dbwrap_watched_do_locked_state *state =
+                       rec->private_data;
+               subrec = &state->subrec;
+       } else {
+               subrec = talloc_get_type_abort(
+                       rec->private_data, struct db_watched_subrec);
+       }
+
+       dbwrap_watched_subrec_wakeup(rec, subrec);
+}
+
 struct db_context *db_open_watched(TALLOC_CTX *mem_ctx,
                                   struct db_context **backend,
                                   struct messaging_context *msg)
index a836ca48e8aa6e5a39427d017212df8e194bb77d..c380c434c856edcb65997c5fb84eecad12526437 100644 (file)
@@ -35,4 +35,12 @@ NTSTATUS dbwrap_watched_watch_recv(struct tevent_req *req,
                                   bool *blockerdead,
                                   struct server_id *blocker);
 
+/*
+ * Wake up watchers without having modified the record value. One
+ * usecase at the time of this commit is: We have lease break waiters
+ * waiting on a locking.tdb record. They should be woken up when a
+ * lease is broken, which does not modify the locking.tdb record.
+ */
+void dbwrap_watched_wakeup(struct db_record *rec);
+
 #endif /* __DBWRAP_WATCH_H__ */