summaryrefslogtreecommitdiffstats
path: root/ctdb/tcp/tcp_connect.c
diff options
context:
space:
mode:
authorRonnie Sahlberg <ronniesahlberg@gmail.com>2012-05-10 17:40:22 +1000
committerRonnie Sahlberg <ronniesahlberg@gmail.com>2012-05-10 17:42:06 +1000
commitdfdec4a07c8d8ba938fbe6976138b93027b7655c (patch)
tree0d41011cf38a6abdef05ee27a0b90a95ffe7b03c /ctdb/tcp/tcp_connect.c
parenta57eba2bb49b32f3dc69542de69b8b74ec9d3d09 (diff)
downloadsamba-dfdec4a07c8d8ba938fbe6976138b93027b7655c.tar.gz
samba-dfdec4a07c8d8ba938fbe6976138b93027b7655c.tar.xz
samba-dfdec4a07c8d8ba938fbe6976138b93027b7655c.zip
We dont need to serialize the "probe which address this node is" if we have given an explicit --node-ip on the commandline
(This used to be ctdb commit e3dc5bd3f1ef1f0ed08f57a5b5bafcac936e9ed0)
Diffstat (limited to 'ctdb/tcp/tcp_connect.c')
-rw-r--r--ctdb/tcp/tcp_connect.c47
1 files changed, 27 insertions, 20 deletions
diff --git a/ctdb/tcp/tcp_connect.c b/ctdb/tcp/tcp_connect.c
index 0e1318f9c0..2814201f92 100644
--- a/ctdb/tcp/tcp_connect.c
+++ b/ctdb/tcp/tcp_connect.c
@@ -281,26 +281,29 @@ static int ctdb_tcp_listen_automatic(struct ctdb_context *ctdb)
int sock_size;
struct tevent_fd *fde;
- /* 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;
- }
+ /* 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;
+ }
- 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++) {
@@ -399,11 +402,15 @@ static int ctdb_tcp_listen_automatic(struct ctdb_context *ctdb)
ctdb_listen_event, ctdb);
tevent_fd_set_auto_close(fde);
- close(lock_fd);
+ if (!ctdb->node_ip) {
+ close(lock_fd);
+ }
return 0;
failed:
- close(lock_fd);
+ if (!ctdb->node_ip) {
+ close(lock_fd);
+ }
close(ctcp->listen_fd);
ctcp->listen_fd = -1;
return -1;