aboutsummaryrefslogtreecommitdiff
path: root/socket.c
diff options
context:
space:
mode:
authorjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2005-11-28 04:59:19 +0000
committerjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2005-11-28 04:59:19 +0000
commita17f69699e9f5aef720914781cd9df56cb36cc13 (patch)
treed8d57dfa1e56e0700562811aae181616523d686c /socket.c
parentAdded --connect-timeout option to control the timeout (diff)
downloadopenvpn-a17f69699e9f5aef720914781cd9df56cb36cc13.tar.xz
Modified nonblocking connect code so that this works as it should:
./openvpn --dev tap --proto tcp-client --verb 4 --remote [Black-Hole-IP-Addr] --connect-retry-max 1 --remap-usr1 SIGTERM git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@826 e7ae566f-a301-0410-adde-c780ea21d3b5
Diffstat (limited to '')
-rw-r--r--socket.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/socket.c b/socket.c
index 2a85191..54a24b2 100644
--- a/socket.c
+++ b/socket.c
@@ -811,10 +811,9 @@ socket_connect (socket_descriptor_t *sd,
while (true)
{
- const int status = openvpn_connect (*sd, remote, connect_timeout, signal_received);
+ int status;
- if (connect_retry_max != 0 && retry++ >= connect_retry_max)
- *signal_received = SIGUSR1;
+ status = openvpn_connect (*sd, remote, connect_timeout, signal_received);
get_signal (signal_received);
if (*signal_received)
@@ -830,8 +829,20 @@ socket_connect (socket_descriptor_t *sd,
strerror_ts (status, &gc));
openvpn_close_socket (*sd);
+ *sd = SOCKET_UNDEFINED;
+
+ if (connect_retry_max > 0 && ++retry >= connect_retry_max)
+ {
+ *signal_received = SIGUSR1;
+ goto done;
+ }
+
openvpn_sleep (connect_retry_seconds);
+ get_signal (signal_received);
+ if (*signal_received)
+ goto done;
+
if (remote_list)
{
remote_list_next (remote_list);