daemon: Use ctdb_is_frozen() to check if databases are frozen
authorAmitay Isaacs <amitay@gmail.com>
Thu, 21 Aug 2014 02:32:02 +0000 (12:32 +1000)
committerAmitay Isaacs <amitay@gmail.com>
Tue, 3 Mar 2015 01:28:54 +0000 (12:28 +1100)
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
server/ctdb_banning.c
server/ctdb_control.c
server/ctdb_recover.c

index a9d18910a06934a3790a7d0690383ac97f84e935..50df54d7975461afc9ec730bc5a6560704f56189 100644 (file)
@@ -31,17 +31,9 @@ ctdb_ban_node_event(struct event_context *ev, struct timed_event *te,
                               struct timeval t, void *private_data)
 {
        struct ctdb_context *ctdb = talloc_get_type(private_data, struct ctdb_context);
-       bool freeze_failed = false;
-       int i;
 
        /* Make sure we were able to freeze databases during banning */
-       for (i=1; i<=NUM_DB_PRIORITIES; i++) {
-               if (ctdb->freeze_mode[i] != CTDB_FREEZE_FROZEN) {
-                       freeze_failed = true;
-                       break;
-               }
-       }
-       if (freeze_failed) {
+       if (!ctdb_is_frozen(ctdb)) {
                DEBUG(DEBUG_ERR, ("Banning timedout, but still unable to freeze databases\n"));
                ctdb_ban_self(ctdb);
                return;
index ce4181fd971997cfbdde829dcdfca2038516777a..988f3d5859a1eb32b259f0ba5fe20a4be3949844 100644 (file)
@@ -120,16 +120,10 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
        }
 
        case CTDB_CONTROL_STATISTICS: {
-               int i;
                CHECK_CONTROL_DATA_SIZE(0);
                ctdb->statistics.memory_used = talloc_total_size(NULL);
                ctdb->statistics.num_clients = ctdb->num_clients;
-               ctdb->statistics.frozen = 0;
-               for (i=1; i<= NUM_DB_PRIORITIES; i++) {
-                       if (ctdb->freeze_mode[i] == CTDB_FREEZE_FROZEN) {
-                               ctdb->statistics.frozen = 1;
-                       }
-               }
+               ctdb->statistics.frozen = (ctdb_is_frozen(ctdb) ? 1 : 0);
                ctdb->statistics.recovering = (ctdb->recovery_mode == CTDB_RECOVERY_ACTIVE);
                ctdb->statistics.statistics_current_time = timeval_current();
 
index 50bcf25a6a1d4388a0443586b4a7c6aa4a4685d4..b40138c12c51b5e13f2040b1eb8f445530ac6b27 100644 (file)
@@ -53,13 +53,10 @@ int
 ctdb_control_setvnnmap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata)
 {
        struct ctdb_vnn_map_wire *map = (struct ctdb_vnn_map_wire *)indata.dptr;
-       int i;
 
-       for(i=1; i<=NUM_DB_PRIORITIES; i++) {
-               if (ctdb->freeze_mode[i] != CTDB_FREEZE_FROZEN) {
-                       DEBUG(DEBUG_ERR,("Attempt to set vnnmap when not frozen\n"));
-                       return -1;
-               }
+       if (!ctdb_is_frozen(ctdb)) {
+               DEBUG(DEBUG_ERR,("Attempt to set vnnmap when not frozen\n"));
+               return -1;
        }
 
        talloc_free(ctdb->vnn_map);