dont just exit(0) upon successful completion of waiting for an ipreallocate to finish.
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 9 Feb 2010 03:35:10 +0000 (14:35 +1100)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 9 Feb 2010 03:35:10 +0000 (14:35 +1100)
return success back to the caller instead.

otherwise things like 'ctdb enable -n all' will just finish after the first disabled node has become enabled.

tools/ctdb.c

index 1c760d40a8043fdee9c9d341eb0a2f1152dda006..dbc8b47b13d85bda8f64269b1170aaf19de9214d 100644 (file)
@@ -1939,13 +1939,15 @@ static int control_getpid(struct ctdb_context *ctdb, int argc, const char **argv
        return 0;
 }
 
+static uint32_t ipreallocate_finished;
+
 /*
   handler for receiving the response to ipreallocate
 */
 static void ip_reallocate_handler(struct ctdb_context *ctdb, uint64_t srvid, 
                             TDB_DATA data, void *private_data)
 {
-       exit(0);
+       ipreallocate_finished = 1;
 }
 
 static void ctdb_every_second(struct event_context *ev, struct timed_event *te, struct timeval t, void *p)
@@ -2056,6 +2058,7 @@ again:
                goto again;
        } 
 
+       ipreallocate_finished = 0;
        ret = ctdb_send_message(ctdb, recmaster, CTDB_SRVID_TAKEOVER_RUN, data);
        if (ret != 0) {
                DEBUG(DEBUG_ERR,("Failed to send ip takeover run request message to %u\n", options.pnn));
@@ -2067,6 +2070,9 @@ again:
        while (timeval_elapsed(&tv) < 3.0) {    
                event_loop_once(ctdb->ev);
        }
+       if (ipreallocate_finished == 1) {
+               return 0;
+       }
 
        DEBUG(DEBUG_INFO,("Timed out waiting for recmaster ipreallocate. Trying again\n"));
        retries++;
@@ -2129,6 +2135,7 @@ static int control_enable(struct ctdb_context *ctdb, int argc, const char **argv
 
        struct ctdb_node_map *nodemap=NULL;
 
+
        /* check if the node is already enabled */
        if (ctdb_ctrl_getnodemap(ctdb, TIMELIMIT(), CTDB_CURRENT_NODE, ctdb, &nodemap) != 0) {
                DEBUG(DEBUG_ERR, ("Unable to get nodemap from local node\n"));
@@ -2155,6 +2162,7 @@ static int control_enable(struct ctdb_context *ctdb, int argc, const char **argv
                }
 
        } while (nodemap->nodes[options.pnn].flags & NODE_FLAGS_PERMANENTLY_DISABLED);
+
        ret = control_ipreallocate(ctdb, argc, argv);
        if (ret != 0) {
                DEBUG(DEBUG_ERR, ("IP Reallocate failed on node %u\n", options.pnn));