lib: Remove g_lock_do()
authorVolker Lendecke <vl@samba.org>
Thu, 10 Oct 2019 11:40:44 +0000 (13:40 +0200)
committerJeremy Allison <jra@samba.org>
Wed, 6 Nov 2019 20:36:34 +0000 (20:36 +0000)
This puts too much logic into this lowlevel infrastructure module,
given the two minor external users.

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 c3e3a509b80f013a998d160dcb4e0cee33bdc91d..782a2e9d160e522b2a8030029695a416b1436b29 100644 (file)
@@ -51,10 +51,6 @@ 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(TDB_DATA key, enum g_lock_type lock_type,
-                  struct timeval timeout,
-                  void (*fn)(void *private_data), void *private_data);
-
 int g_lock_locks(struct g_lock_ctx *ctx,
                 int (*fn)(TDB_DATA key, void *private_data),
                 void *private_data);
index 5940c51c1d3ff9ba46cefcebb96f61e213a3cf85..43cb123661eb1194102041921107c75ec889c5f9 100644 (file)
@@ -750,67 +750,3 @@ NTSTATUS g_lock_dump(struct g_lock_ctx *ctx, TDB_DATA key,
        }
        return NT_STATUS_OK;
 }
-
-static bool g_lock_init_all(TALLOC_CTX *mem_ctx,
-                           struct tevent_context **pev,
-                           struct messaging_context **pmsg,
-                           struct g_lock_ctx **pg_ctx)
-{
-       struct tevent_context *ev = NULL;
-       struct messaging_context *msg = NULL;
-       struct g_lock_ctx *g_ctx = NULL;
-
-       ev = samba_tevent_context_init(mem_ctx);
-       if (ev == NULL) {
-               d_fprintf(stderr, "ERROR: could not init event context\n");
-               goto fail;
-       }
-       msg = messaging_init(mem_ctx, ev);
-       if (msg == NULL) {
-               d_fprintf(stderr, "ERROR: could not init messaging context\n");
-               goto fail;
-       }
-       g_ctx = g_lock_ctx_init(mem_ctx, msg);
-       if (g_ctx == NULL) {
-               d_fprintf(stderr, "ERROR: could not init g_lock context\n");
-               goto fail;
-       }
-
-       *pev = ev;
-       *pmsg = msg;
-       *pg_ctx = g_ctx;
-       return true;
-fail:
-       TALLOC_FREE(g_ctx);
-       TALLOC_FREE(msg);
-       TALLOC_FREE(ev);
-       return false;
-}
-
-NTSTATUS g_lock_do(TDB_DATA key, enum g_lock_type lock_type,
-                  struct timeval timeout,
-                  void (*fn)(void *private_data), void *private_data)
-{
-       struct tevent_context *ev = NULL;
-       struct messaging_context *msg = NULL;
-       struct g_lock_ctx *g_ctx = NULL;
-       NTSTATUS status;
-
-       if (!g_lock_init_all(talloc_tos(), &ev, &msg, &g_ctx)) {
-               status = NT_STATUS_ACCESS_DENIED;
-               goto done;
-       }
-
-       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, key);
-
-done:
-       TALLOC_FREE(g_ctx);
-       TALLOC_FREE(msg);
-       TALLOC_FREE(ev);
-       return status;
-}