aboutsummaryrefslogtreecommitdiff
path: root/socket.c
diff options
context:
space:
mode:
authorjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2005-11-09 08:36:26 +0000
committerjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2005-11-09 08:36:26 +0000
commitb540a9e07571aaaeea5cc2b81e695829d228c2f1 (patch)
treee7e2e86384943f6e5541865970aedf88b7590488 /socket.c
parentRemoved annoying 'i' variable from add_option. (diff)
downloadopenvpn-b540a9e07571aaaeea5cc2b81e695829d228c2f1.tar.xz
Merged (with some changes) Alon's
connect-retry-max option from /contrib/alon/BETA21@783. Added uninit_management_callback call to init_instance_handle_signals so that signals thrown during initialization can bring us back to a management hold. git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@786 e7ae566f-a301-0410-adde-c780ea21d3b5
Diffstat (limited to 'socket.c')
-rw-r--r--socket.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/socket.c b/socket.c
index b7a25ca..ab6d6ee 100644
--- a/socket.c
+++ b/socket.c
@@ -721,9 +721,11 @@ socket_connect (socket_descriptor_t *sd,
const char *remote_dynamic,
bool *remote_changed,
const int connect_retry_seconds,
+ const int connect_retry_max,
volatile int *signal_received)
{
struct gc_arena gc = gc_new ();
+ int retry = 0;
msg (M_INFO, "Attempting to establish TCP connection with %s",
print_sockaddr (remote, &gc));
@@ -732,6 +734,9 @@ socket_connect (socket_descriptor_t *sd,
const int status = connect (*sd, (struct sockaddr *) &remote->sa,
sizeof (remote->sa));
+ if (connect_retry_max != 0 && retry++ >= connect_retry_max)
+ *signal_received = SIGUSR1;
+
get_signal (signal_received);
if (*signal_received)
goto done;
@@ -987,6 +992,7 @@ link_socket_init_phase1 (struct link_socket *sock,
const struct plugin_list *plugins,
int resolve_retry_seconds,
int connect_retry_seconds,
+ int connect_retry_max,
int mtu_discover_type,
int rcvbuf,
int sndbuf,
@@ -1017,6 +1023,7 @@ link_socket_init_phase1 (struct link_socket *sock,
sock->inetd = inetd;
sock->resolve_retry_seconds = resolve_retry_seconds;
sock->connect_retry_seconds = connect_retry_seconds;
+ sock->connect_retry_max = connect_retry_max;
sock->mtu_discover_type = mtu_discover_type;
#ifdef ENABLE_DEBUG
@@ -1215,6 +1222,7 @@ link_socket_init_phase2 (struct link_socket *sock,
remote_dynamic,
&remote_changed,
sock->connect_retry_seconds,
+ sock->connect_retry_max,
signal_received);
if (*signal_received)
@@ -1255,6 +1263,7 @@ link_socket_init_phase2 (struct link_socket *sock,
remote_dynamic,
&remote_changed,
sock->connect_retry_seconds,
+ sock->connect_retry_max,
signal_received);
if (*signal_received)