From: Volker Lendecke Date: Sun, 3 Dec 2017 19:47:02 +0000 (+0100) Subject: lib: Make g_lock_do use TDB_DATA X-Git-Tag: tevent-0.9.36~188 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a6c749e76cd4f3be0f3a0db81324491314b949c0;p=thirdparty%2Fsamba.git lib: Make g_lock_do use TDB_DATA Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme --- diff --git a/source3/include/g_lock.h b/source3/include/g_lock.h index 20cee4c1a43..dcdb8eee73a 100644 --- a/source3/include/g_lock.h +++ b/source3/include/g_lock.h @@ -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); diff --git a/source3/lib/g_lock.c b/source3/lib/g_lock.c index 45a90a20df8..8b634e8bf64 100644 --- a/source3/lib/g_lock.c +++ b/source3/lib/g_lock.c @@ -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); diff --git a/source3/utils/net_g_lock.c b/source3/utils/net_g_lock.c index 0ec6846d10b..ad749c28cf7 100644 --- a/source3/utils/net_g_lock.c +++ b/source3/utils/net_g_lock.c @@ -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)) { diff --git a/source3/utils/net_registry.c b/source3/utils/net_registry.c index afc99d58873..c67a148ddd0 100644 --- a/source3/utils/net_registry.c +++ b/source3/utils/net_registry.c @@ -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"),