summaryrefslogtreecommitdiffstats
path: root/ctdb/tcp/tcp_connect.c
diff options
context:
space:
mode:
Diffstat (limited to 'ctdb/tcp/tcp_connect.c')
-rw-r--r--ctdb/tcp/tcp_connect.c58
1 files changed, 21 insertions, 37 deletions
diff --git a/ctdb/tcp/tcp_connect.c b/ctdb/tcp/tcp_connect.c
index c94b88f670..26a280e30b 100644
--- a/ctdb/tcp/tcp_connect.c
+++ b/ctdb/tcp/tcp_connect.c
@@ -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;