ctdb-cluster-mutex: Drop cluster_mutex_handler() ctdb and handle arguments
authorMartin Schwenke <martin@meltin.net>
Wed, 1 Jun 2016 07:10:26 +0000 (17:10 +1000)
committerMartin Schwenke <martins@samba.org>
Tue, 7 Jun 2016 22:51:29 +0000 (00:51 +0200)
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 <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/server/ctdb_cluster_mutex.c
ctdb/server/ctdb_cluster_mutex.h
ctdb/server/ctdb_recover.c
ctdb/server/ctdb_recoverd.c

index c8eaae909166412eb1eb9291bdd07af880e1aba5..cef64166aa869f579a1ee5c4e08bed804bdd6dea 100644 (file)
@@ -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);
        }
 }
 
index e76fdc7834f171bd8de0aa9004d33d98e8d68899..efe089261bd0a3e1a7844fb5b07d9372523c3b24 100644 (file)
 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,
index 94732a8c5d5a6e742a1608899c24fe1943ea93ed..1742e34bb268593cb7940e00af63ae8939f4b06e 100644 (file)
@@ -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);
index f3167ff960220c2e90fbaeaa4900419b871427b0..f22a11b3afe1635aa89e7a5fa12f3e345cd64c17 100644 (file)
@@ -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 =