From 90d7784d45d2a43f5e8a68596c793e7ba8a5b350 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 18 May 2017 15:27:46 +0200 Subject: [PATCH] g_lock: Make g_lock_dump return a complete list of locks To be honest, it did not really make sense to just pass in lock holders individually. You could argue that it made sense with in reality only G_LOCK_WRITE around, but soon we will have G_LOCK_READ and thus multiple lock holders on a single lock. Now that we also have userdata, change the g_lock_dump API Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- source3/include/g_lock.h | 13 ++++++++++--- source3/lib/g_lock.c | 30 +++++++++++++----------------- source3/utils/net_g_lock.c | 19 +++++++++++++------ 3 files changed, 36 insertions(+), 26 deletions(-) diff --git a/source3/include/g_lock.h b/source3/include/g_lock.h index f79e0ceef99..e6d4de14cf3 100644 --- a/source3/include/g_lock.h +++ b/source3/include/g_lock.h @@ -30,6 +30,11 @@ enum g_lock_type { G_LOCK_WRITE = 1, }; +struct g_lock_rec { + enum g_lock_type lock_type; + struct server_id pid; +}; + struct g_lock_ctx *g_lock_ctx_init(TALLOC_CTX *mem_ctx, struct messaging_context *msg); @@ -54,9 +59,11 @@ int g_lock_locks(struct g_lock_ctx *ctx, int (*fn)(const char *name, void *private_data), void *private_data); NTSTATUS g_lock_dump(struct g_lock_ctx *ctx, const char *name, - int (*fn)(struct server_id pid, - enum g_lock_type lock_type, - void *private_data), + void (*fn)(const struct g_lock_rec *locks, + size_t num_locks, + const uint8_t *data, + size_t datalen, + void *private_data), void *private_data); #endif diff --git a/source3/lib/g_lock.c b/source3/lib/g_lock.c index f6c35bb1bcc..db2f62ad9d4 100644 --- a/source3/lib/g_lock.c +++ b/source3/lib/g_lock.c @@ -40,11 +40,6 @@ struct g_lock_ctx { * structures. */ -struct g_lock_rec { - enum g_lock_type lock_type; - struct server_id pid; -}; - #define G_LOCK_REC_LENGTH (SERVER_ID_BUF_LENGTH+1) static void g_lock_rec_put(uint8_t buf[G_LOCK_REC_LENGTH], @@ -637,14 +632,18 @@ int g_lock_locks(struct g_lock_ctx *ctx, } NTSTATUS g_lock_dump(struct g_lock_ctx *ctx, const char *name, - int (*fn)(struct server_id pid, - enum g_lock_type lock_type, - void *private_data), + void (*fn)(const struct g_lock_rec *locks, + size_t num_locks, + const uint8_t *data, + size_t datalen, + void *private_data), void *private_data) { TDB_DATA data; - size_t i, num_locks; + size_t num_locks; struct g_lock_rec *locks = NULL; + uint8_t *userdata; + size_t userdatalen; NTSTATUS status; status = dbwrap_fetch_bystring(ctx->db, talloc_tos(), name, &data); @@ -657,22 +656,19 @@ NTSTATUS g_lock_dump(struct g_lock_ctx *ctx, const char *name, } status = g_lock_get_talloc(talloc_tos(), data, &locks, &num_locks, - NULL, NULL); - - TALLOC_FREE(data.dptr); + &userdata, &userdatalen); if (!NT_STATUS_IS_OK(status)) { DBG_DEBUG("g_lock_get for %s failed: %s\n", name, nt_errstr(status)); + TALLOC_FREE(data.dptr); return NT_STATUS_INTERNAL_ERROR; } - for (i=0; ipid, &idbuf), + (l->lock_type & 1) ? "WRITE" : "READ"); + } } static int net_g_lock_dump(struct net_context *c, int argc, const char **argv) -- 2.11.4.GIT