ctdbd: Remove debug option --node-ip, use --listen instead
authorMartin Schwenke <martin@meltin.net>
Mon, 3 Dec 2012 04:44:12 +0000 (15:44 +1100)
committerAmitay Isaacs <amitay@gmail.com>
Sun, 6 Jan 2013 23:35:39 +0000 (10:35 +1100)
This effectively reverts d96cb02c2c24f9eabbc53d3d38e90dea49cff3e0

Signed-off-by: Martin Schwenke <martin@meltin.net>
Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>

include/ctdb_private.h
server/ctdbd.c
tcp/tcp_connect.c

index 582a7677c054f9f1df9c93202527585a231fae8a..152af64f684ff0b159651cc2ef25eac7ac7f6105 100644 (file)
@@ -501,7 +501,6 @@ struct ctdb_context {
        pid_t recoverd_pid;
        pid_t syslogd_pid;
        bool done_startup;
-       const char *node_ip;
        struct ctdb_monitor_state *monitor;
        struct ctdb_log_state *log;
        int start_as_disabled;
index ddda8ffbe21c0071608f0cbc7fdeb21c12ee24c8..bcc950266a46201b46cea9dc78d15d29dc076dc2 100644 (file)
@@ -41,7 +41,6 @@ static struct {
        const char *db_dir_state;
        const char *public_interface;
        const char *single_public_ip;
-       const char *node_ip;
        int         valgrinding;
        int         nosetsched;
        int         use_syslog;
@@ -126,7 +125,6 @@ int main(int argc, const char *argv[])
                { "event-script-dir", 0, POPT_ARG_STRING, &options.event_script_dir, 0, "event script directory", "dirname" },
                { "logfile", 0, POPT_ARG_STRING, &options.logfile, 0, "log file location", "filename" },
                { "nlist", 0, POPT_ARG_STRING, &options.nlist, 0, "node list file", "filename" },
-               { "node-ip", 0, POPT_ARG_STRING, &options.node_ip, 0, "node ip", "ip-address"},
                { "notification-script", 0, POPT_ARG_STRING, &options.notification_script, 0, "notification script", "filename" },
                { "debug-hung-script", 0, POPT_ARG_STRING, &options.debug_hung_script, 0, "debug script for hung eventscripts", "filename" },
                { "listen", 0, POPT_ARG_STRING, &options.myaddress, 0, "address to listen on", "address" },
@@ -247,20 +245,6 @@ int main(int argc, const char *argv[])
        /* tell ctdb what nodes are available */
        ctdb_load_nodes_file(ctdb);
 
-       /* if a node-ip was specified, verify that it exists in the
-          nodes file
-       */
-       if (options.node_ip != NULL) {
-               DEBUG(DEBUG_NOTICE,("IP for this node is %s\n", options.node_ip));
-               ret = ctdb_ip_to_nodeid(ctdb, options.node_ip);
-               if (ret == -1) {
-                       DEBUG(DEBUG_ALERT,("The specified node-ip:%s is not a valid node address. Exiting.\n", options.node_ip));
-                       exit(1);
-               }
-               ctdb->node_ip = options.node_ip;
-               DEBUG(DEBUG_NOTICE,("This is node %d\n", ret));
-       }
-
        if (options.db_dir) {
                ret = ctdb_set_tdb_dir(ctdb, options.db_dir);
                if (ret == -1) {
index c94b88f6709008591e21fd9fd52d3bbeb08e7d5e..26a280e30ba4a5d73c592278696250555e00343d 100644 (file)
@@ -290,45 +290,32 @@ static int ctdb_tcp_listen_automatic(struct ctdb_context *ctdb)
                return -1;
        }
 
-       /* We only need to serialize this if we dont yet know the node ip */
-       if (!ctdb->node_ip) {
-               /* in order to ensure that we don't get two nodes with the
-                  same adddress, we must make the bind() and listen() calls
-                  atomic. The SO_REUSEADDR setsockopt only prevents double
-                  binds if the first socket is in LISTEN state  */
-               lock_fd = open(lock_path, O_RDWR|O_CREAT, 0666);
-               if (lock_fd == -1) {
-                       DEBUG(DEBUG_CRIT,("Unable to open %s\n", lock_path));
-                       return -1;
-               }
+       /* in order to ensure that we don't get two nodes with the
+          same adddress, we must make the bind() and listen() calls
+          atomic. The SO_REUSEADDR setsockopt only prevents double
+          binds if the first socket is in LISTEN state  */
+       lock_fd = open(lock_path, O_RDWR|O_CREAT, 0666);
+       if (lock_fd == -1) {
+               DEBUG(DEBUG_CRIT,("Unable to open %s\n", lock_path));
+               return -1;
+       }
 
-               lock.l_type = F_WRLCK;
-               lock.l_whence = SEEK_SET;
-               lock.l_start = 0;
-               lock.l_len = 1;
-               lock.l_pid = 0;
+       lock.l_type = F_WRLCK;
+       lock.l_whence = SEEK_SET;
+       lock.l_start = 0;
+       lock.l_len = 1;
+       lock.l_pid = 0;
 
-               if (fcntl(lock_fd, F_SETLKW, &lock) != 0) {
-                       DEBUG(DEBUG_CRIT,("Unable to lock %s\n", lock_path));
-                       close(lock_fd);
-                       return -1;
-               }
+       if (fcntl(lock_fd, F_SETLKW, &lock) != 0) {
+               DEBUG(DEBUG_CRIT,("Unable to lock %s\n", lock_path));
+               close(lock_fd);
+               return -1;
        }
 
        for (i=0; i < ctdb->num_nodes; i++) {
                if (ctdb->nodes[i]->flags & NODE_FLAGS_DELETED) {
                        continue;
                }
-
-               /* if node_ip is specified we will only try to bind to that
-                  ip.
-               */
-               if (ctdb->node_ip != NULL) {
-                       if (strcmp(ctdb->node_ip, ctdb->nodes[i]->address.address)) {
-                               continue;
-                       }
-               }
-
                ZERO_STRUCT(sock);
                if (ctdb_tcp_get_address(ctdb,
                                ctdb->nodes[i]->address.address, 
@@ -411,15 +398,12 @@ static int ctdb_tcp_listen_automatic(struct ctdb_context *ctdb)
                           ctdb_listen_event, ctdb);
        tevent_fd_set_auto_close(fde);
 
-       if (!ctdb->node_ip) {
-               close(lock_fd);
-       }
+       close(lock_fd);
+
        return 0;
        
 failed:
-       if (!ctdb->node_ip) {
-               close(lock_fd);
-       }
+       close(lock_fd);
        close(ctcp->listen_fd);
        ctcp->listen_fd = -1;
        return -1;