]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib: Add g_lock_wake_watchers()
authorVolker Lendecke <vl@samba.org>
Mon, 4 Nov 2019 15:03:52 +0000 (16:03 +0100)
committerJeremy Allison <jra@samba.org>
Fri, 15 May 2020 00:48:32 +0000 (00:48 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/include/g_lock.h
source3/lib/g_lock.c

index 98321b629ec66d0c417682233d296d68396cb1f9..77f013587050fdadf6630ea29537e6449e9e00ed 100644 (file)
@@ -75,5 +75,6 @@ NTSTATUS g_lock_watch_data_recv(
        struct tevent_req *req,
        bool *blockerdead,
        struct server_id *blocker);
+void g_lock_wake_watchers(struct g_lock_ctx *ctx, TDB_DATA key);
 
 #endif
index fc6232b7dc571e672691fe298ff820eacafc93d6..6898de88bc21a325d13f92f2bb950b2be688daa2 100644 (file)
@@ -1241,3 +1241,38 @@ NTSTATUS g_lock_watch_data_recv(
 
        return NT_STATUS_OK;
 }
+
+static void g_lock_wake_watchers_fn(
+       struct db_record *rec,
+       TDB_DATA value,
+       void *private_data)
+{
+       struct g_lock lck = { .exclusive.pid = 0 };
+       NTSTATUS status;
+       bool ok;
+
+       ok = g_lock_parse(value.dptr, value.dsize, &lck);
+       if (!ok) {
+               DBG_WARNING("g_lock_parse failed\n");
+               return;
+       }
+
+       lck.data_seqnum += 1;
+
+       status = g_lock_store(rec, &lck, NULL);
+       if (!NT_STATUS_IS_OK(status)) {
+               DBG_WARNING("g_lock_store failed: %s\n", nt_errstr(status));
+               return;
+       }
+}
+
+void g_lock_wake_watchers(struct g_lock_ctx *ctx, TDB_DATA key)
+{
+       NTSTATUS status;
+
+       status = dbwrap_do_locked(ctx->db, key, g_lock_wake_watchers_fn, NULL);
+       if (!NT_STATUS_IS_OK(status)) {
+               DBG_DEBUG("dbwrap_do_locked returned %s\n",
+                         nt_errstr(status));
+       }
+}