If the socket is set non-blocking before connect, then we should catch
EAGAIN errors and retry. Instead of adding a random number of retries,
better to wait for connect to succeed and then set the socket to
non-blocking.
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit
524ec206e6a5e8b11723f4d8d1251ed5d84063b0)
return -1;
}
- set_nonblocking(ctdb->daemon.sd);
- set_close_on_exec(ctdb->daemon.sd);
-
if (connect(ctdb->daemon.sd, (struct sockaddr *)&addr, sizeof(addr)) == -1) {
close(ctdb->daemon.sd);
ctdb->daemon.sd = -1;
return -1;
}
+ set_nonblocking(ctdb->daemon.sd);
+ set_close_on_exec(ctdb->daemon.sd);
+
ctdb->daemon.queue = ctdb_queue_setup(ctdb, ctdb, ctdb->daemon.sd,
CTDB_DS_ALIGNMENT,
ctdb_client_read_cb, ctdb, "to-ctdbd");
if (ctdb->fd < 0)
goto free_fail;
- set_nonblocking(ctdb->fd);
- set_close_on_exec(ctdb->fd);
-
if (connect(ctdb->fd, (struct sockaddr *)&sun, sizeof(sun)) == -1)
goto close_fail;
+ set_nonblocking(ctdb->fd);
+ set_close_on_exec(ctdb->fd);
+
/* Immediately queue a request to get our pnn. */
if (!ctdb_getpnn_send(ctdb, CTDB_CURRENT_NODE, set_pnn, NULL))
goto close_fail;