From 3b7b979ee987e3561caec35b277abe74c996fa9c Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 24 May 2019 15:00:45 +0200 Subject: [PATCH] dbwrap: Add publically available dbwrap_watch_wakeup() 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 Reviewed-by: Ralph Boehme --- source3/lib/dbwrap/dbwrap_watch.c | 16 ++++++++++++++++ source3/lib/dbwrap/dbwrap_watch.h | 8 ++++++++ 2 files changed, 24 insertions(+) diff --git a/source3/lib/dbwrap/dbwrap_watch.c b/source3/lib/dbwrap/dbwrap_watch.c index 61c713b3b61..9bf3d372621 100644 --- a/source3/lib/dbwrap/dbwrap_watch.c +++ b/source3/lib/dbwrap/dbwrap_watch.c @@ -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) diff --git a/source3/lib/dbwrap/dbwrap_watch.h b/source3/lib/dbwrap/dbwrap_watch.h index a836ca48e8a..c380c434c85 100644 --- a/source3/lib/dbwrap/dbwrap_watch.h +++ b/source3/lib/dbwrap/dbwrap_watch.h @@ -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__ */ -- 2.47.3