From: Martin Schwenke Date: Wed, 1 Jun 2016 08:56:33 +0000 (+1000) Subject: ctdb-cluster-mutex: ctdb_cluster_mutex() registers handler and private data X-Git-Tag: tdb-1.3.10~920 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4f0ca0107c83ca0da3e676975543adcbb122b0b9;p=thirdparty%2Fsamba.git ctdb-cluster-mutex: ctdb_cluster_mutex() registers handler and private data Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/server/ctdb_cluster_mutex.c b/ctdb/server/ctdb_cluster_mutex.c index cef64166aa8..fbeeb92fb6b 100644 --- a/ctdb/server/ctdb_cluster_mutex.c +++ b/ctdb/server/ctdb_cluster_mutex.c @@ -48,14 +48,6 @@ struct ctdb_cluster_mutex_handle { bool have_response; }; -void ctdb_cluster_mutex_set_handler(struct ctdb_cluster_mutex_handle *h, - cluster_mutex_handler_t handler, - void *private_data) -{ - h->handler = handler; - h->private_data = private_data; -} - static void cluster_mutex_timeout(struct tevent_context *ev, struct tevent_timer *te, struct timeval t, void *private_data) @@ -186,7 +178,9 @@ struct ctdb_cluster_mutex_handle * ctdb_cluster_mutex(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb, const char *argstring, - int timeout) + int timeout, + cluster_mutex_handler_t handler, + void *private_data) { struct ctdb_cluster_mutex_handle *h; char **args; @@ -268,8 +262,8 @@ ctdb_cluster_mutex(TALLOC_CTX *mem_ctx, tevent_fd_set_auto_close(h->fde); h->ctdb = ctdb; - h->handler = NULL; - h->private_data = NULL; + h->handler = handler; + h->private_data = private_data; return h; } diff --git a/ctdb/server/ctdb_cluster_mutex.h b/ctdb/server/ctdb_cluster_mutex.h index efe089261bd..2f5de045e69 100644 --- a/ctdb/server/ctdb_cluster_mutex.h +++ b/ctdb/server/ctdb_cluster_mutex.h @@ -36,14 +36,12 @@ typedef void (*cluster_mutex_handler_t) ( double latency, void *private_data); -void ctdb_cluster_mutex_set_handler(struct ctdb_cluster_mutex_handle *h, - cluster_mutex_handler_t handler, - void *private_data); - struct ctdb_cluster_mutex_handle * ctdb_cluster_mutex(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb, const char *argstring, - int timeout); + int timeout, + cluster_mutex_handler_t handler, + void *private_data); #endif /* __CTDB_IPALLOC_H__ */ diff --git a/ctdb/server/ctdb_recover.c b/ctdb/server/ctdb_recover.c index 1742e34bb26..fd44e1c75dc 100644 --- a/ctdb/server/ctdb_recover.c +++ b/ctdb/server/ctdb_recover.c @@ -916,18 +916,14 @@ int32_t ctdb_control_set_recmode(struct ctdb_context *ctdb, state->ctdb = ctdb; state->c = NULL; - h = ctdb_cluster_mutex(state, ctdb, ctdb->recovery_lock, 5); + h = ctdb_cluster_mutex(state, ctdb, ctdb->recovery_lock, 5, + set_recmode_handler, state); if (h == NULL) { talloc_free(state); return -1; } state->c = talloc_steal(state, c); - - /* set_recmode_handler() frees state/h */ - ctdb_cluster_mutex_set_handler(h, - set_recmode_handler, - state); *async_reply = true; return 0; diff --git a/ctdb/server/ctdb_recoverd.c b/ctdb/server/ctdb_recoverd.c index f22a11b3afe..23d2d9ab6e7 100644 --- a/ctdb/server/ctdb_recoverd.c +++ b/ctdb/server/ctdb_recoverd.c @@ -1588,13 +1588,12 @@ static bool ctdb_recovery_lock(struct ctdb_recoverd *rec) .latency = 0, }; - h = ctdb_cluster_mutex(rec, ctdb, ctdb->recovery_lock, 0); + h = ctdb_cluster_mutex(rec, ctdb, ctdb->recovery_lock, 0, + hold_reclock_handler, &s); if (h == NULL) { return false; } - ctdb_cluster_mutex_set_handler(h, hold_reclock_handler, &s); - while (!s.done) { tevent_loop_once(ctdb->ev); }