]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib: Make g_lock_do use TDB_DATA
authorVolker Lendecke <vl@samba.org>
Sun, 3 Dec 2017 19:47:02 +0000 (20:47 +0100)
committerRalph Boehme <slow@samba.org>
Thu, 8 Feb 2018 09:01:50 +0000 (10:01 +0100)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/include/g_lock.h
source3/lib/g_lock.c
source3/utils/net_g_lock.c
source3/utils/net_registry.c

index 20cee4c1a431e953c54c7c9c1bb22fba1d2b51dc..dcdb8eee73abe79c3dc5a6590fc1ffb032f8127f 100644 (file)
@@ -51,7 +51,7 @@ NTSTATUS g_lock_unlock(struct g_lock_ctx *ctx, TDB_DATA key);
 NTSTATUS g_lock_write_data(struct g_lock_ctx *ctx, TDB_DATA key,
                           const uint8_t *buf, size_t buflen);
 
-NTSTATUS g_lock_do(const char *name, enum g_lock_type lock_type,
+NTSTATUS g_lock_do(TDB_DATA key, enum g_lock_type lock_type,
                   struct timeval timeout,
                   void (*fn)(void *private_data), void *private_data);
 
index 45a90a20df85534741927f5c245697dfbd7a6660..8b634e8bf64298b6a751fa7f181075e5bbd35b75 100644 (file)
@@ -773,7 +773,7 @@ fail:
        return false;
 }
 
-NTSTATUS g_lock_do(const char *name, enum g_lock_type lock_type,
+NTSTATUS g_lock_do(TDB_DATA key, enum g_lock_type lock_type,
                   struct timeval timeout,
                   void (*fn)(void *private_data), void *private_data)
 {
@@ -787,13 +787,12 @@ NTSTATUS g_lock_do(const char *name, enum g_lock_type lock_type,
                goto done;
        }
 
-       status = g_lock_lock(g_ctx, string_term_tdb_data(name), lock_type,
-                            timeout);
+       status = g_lock_lock(g_ctx, key, lock_type, timeout);
        if (!NT_STATUS_IS_OK(status)) {
                goto done;
        }
        fn(private_data);
-       g_lock_unlock(g_ctx, string_term_tdb_data(name));
+       g_lock_unlock(g_ctx, key);
 
 done:
        TALLOC_FREE(g_ctx);
index 0ec6846d10b80a402a0e6e398ede4ff39561669a..ad749c28cf7f9f69dc39b6774298c9c97d7c301b 100644 (file)
@@ -22,6 +22,7 @@
 #include "lib/util/server_id.h"
 #include "g_lock.h"
 #include "messages.h"
+#include "lib/util/util_tdb.h"
 
 static bool net_g_lock_init(TALLOC_CTX *mem_ctx,
                            struct tevent_context **pev,
@@ -90,7 +91,7 @@ static int net_g_lock_do(struct net_context *c, int argc, const char **argv)
        state.cmd = cmd;
        state.result = -1;
 
-       status = g_lock_do(name, G_LOCK_WRITE,
+       status = g_lock_do(string_term_tdb_data(name), G_LOCK_WRITE,
                           timeval_set(timeout / 1000, timeout % 1000),
                           net_g_lock_do_fn, &state);
        if (!NT_STATUS_IS_OK(status)) {
index afc99d58873872594e6097e98bc1c61c3e5f0e63..c67a148ddd0aa06836eec8325c4068e2da20a55b 100644 (file)
@@ -37,6 +37,7 @@
 #include "../libcli/registry/util_reg.h"
 #include "passdb/machine_sid.h"
 #include "net_registry_check.h"
+#include "lib/util/util_tdb.h"
 
 /*
  *
@@ -643,8 +644,8 @@ static int net_registry_increment(struct net_context *c, int argc,
                state.increment = strtoul(argv[2], NULL, 10);
        }
 
-       status = g_lock_do("registry_increment_lock", G_LOCK_WRITE,
-                          timeval_set(600, 0),
+       status = g_lock_do(string_term_tdb_data("registry_increment_lock"),
+                          G_LOCK_WRITE, timeval_set(600, 0),
                           net_registry_increment_fn, &state);
        if (!NT_STATUS_IS_OK(status)) {
                d_fprintf(stderr, _("g_lock_do failed: %s\n"),