From: Martin Schwenke Date: Wed, 1 Jun 2016 07:10:26 +0000 (+1000) Subject: ctdb-cluster-mutex: Drop cluster_mutex_handler() ctdb and handle arguments X-Git-Tag: tdb-1.3.10~921 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=145ddcbe37e274aaa1ddbe77acef3129c486c1b0;p=thirdparty%2Fsamba.git ctdb-cluster-mutex: Drop cluster_mutex_handler() ctdb and handle arguments This makes the API more general. If they are needed in a handler then they can be in the 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 c8eaae90916..cef64166aa8 100644 --- a/ctdb/server/ctdb_cluster_mutex.c +++ b/ctdb/server/ctdb_cluster_mutex.c @@ -65,7 +65,7 @@ static void cluster_mutex_timeout(struct tevent_context *ev, double latency = timeval_elapsed(&h->start_time); if (h->handler != NULL) { - h->handler(h->ctdb, '2', latency, h, h->private_data); + h->handler('2', latency, h->private_data); } } @@ -110,8 +110,7 @@ static void cluster_mutex_handler(struct tevent_context *ev, * If no status was written then this is an unexpected error * so pass generic error code to handler. */ if (h->handler != NULL) { - h->handler(h->ctdb, ret == 1 ? c : '3', latency, - h, h->private_data); + h->handler(ret == 1 ? c : '3', latency, h->private_data); } } diff --git a/ctdb/server/ctdb_cluster_mutex.h b/ctdb/server/ctdb_cluster_mutex.h index e76fdc7834f..efe089261bd 100644 --- a/ctdb/server/ctdb_cluster_mutex.h +++ b/ctdb/server/ctdb_cluster_mutex.h @@ -32,10 +32,8 @@ struct ctdb_cluster_mutex_handle; typedef void (*cluster_mutex_handler_t) ( - struct ctdb_context *ctdb, char status, double latency, - struct ctdb_cluster_mutex_handle *h, void *private_data); void ctdb_cluster_mutex_set_handler(struct ctdb_cluster_mutex_handle *h, diff --git a/ctdb/server/ctdb_recover.c b/ctdb/server/ctdb_recover.c index 94732a8c5d5..1742e34bb26 100644 --- a/ctdb/server/ctdb_recover.c +++ b/ctdb/server/ctdb_recover.c @@ -750,13 +750,12 @@ int32_t ctdb_control_db_push_confirm(struct ctdb_context *ctdb, } struct set_recmode_state { + struct ctdb_context *ctdb; struct ctdb_req_control_old *c; }; -static void set_recmode_handler(struct ctdb_context *ctdb, - char status, +static void set_recmode_handler(char status, double latency, - struct ctdb_cluster_mutex_handle *h, void *private_data) { struct set_recmode_state *state = talloc_get_type_abort( @@ -769,7 +768,7 @@ static void set_recmode_handler(struct ctdb_context *ctdb, /* Mutex taken */ DEBUG(DEBUG_ERR, ("ERROR: Daemon able to take recovery lock on \"%s\" during recovery\n", - ctdb->recovery_lock)); + state->ctdb->recovery_lock)); s = -1; err = "Took recovery lock from daemon during recovery - probably a cluster filesystem lock coherence problem"; break; @@ -777,12 +776,12 @@ static void set_recmode_handler(struct ctdb_context *ctdb, case '1': /* Contention */ DEBUG(DEBUG_DEBUG, (__location__ " Recovery lock check OK\n")); - ctdb->recovery_mode = CTDB_RECOVERY_NORMAL; - ctdb_process_deferred_attach(ctdb); + state->ctdb->recovery_mode = CTDB_RECOVERY_NORMAL; + ctdb_process_deferred_attach(state->ctdb); s = 0; - CTDB_UPDATE_RECLOCK_LATENCY(ctdb, "daemon reclock", + CTDB_UPDATE_RECLOCK_LATENCY(state->ctdb, "daemon reclock", reclock.ctdbd, latency); break; @@ -795,8 +794,8 @@ static void set_recmode_handler(struct ctdb_context *ctdb, DEBUG(DEBUG_WARNING, (__location__ "Time out getting recovery lock, allowing recmode set anyway\n")); - ctdb->recovery_mode = CTDB_RECOVERY_NORMAL; - ctdb_process_deferred_attach(ctdb); + state->ctdb->recovery_mode = CTDB_RECOVERY_NORMAL; + ctdb_process_deferred_attach(state->ctdb); s = 0; break; @@ -808,7 +807,7 @@ static void set_recmode_handler(struct ctdb_context *ctdb, err = "Unexpected error when testing recovery lock"; } - ctdb_request_control_reply(ctdb, state->c, NULL, s, err); + ctdb_request_control_reply(state->ctdb, state->c, NULL, s, err); talloc_free(state); } @@ -914,6 +913,7 @@ int32_t ctdb_control_set_recmode(struct ctdb_context *ctdb, DEBUG(DEBUG_ERR, (__location__ " out of memory\n")); return -1; } + state->ctdb = ctdb; state->c = NULL; h = ctdb_cluster_mutex(state, ctdb, ctdb->recovery_lock, 5); diff --git a/ctdb/server/ctdb_recoverd.c b/ctdb/server/ctdb_recoverd.c index f3167ff9602..f22a11b3afe 100644 --- a/ctdb/server/ctdb_recoverd.c +++ b/ctdb/server/ctdb_recoverd.c @@ -1553,10 +1553,8 @@ struct hold_reclock_state { double latency; }; -static void hold_reclock_handler(struct ctdb_context *ctdb, - char status, +static void hold_reclock_handler(char status, double latency, - struct ctdb_cluster_mutex_handle *h, void *private_data) { struct hold_reclock_state *s =