]> tinc-vpn.org Git - tinc/commitdiff
Retry connections through control socket
authorScott Lamb <slamb@slamb.org>
Wed, 7 Nov 2007 02:50:58 +0000 (02:50 +0000)
committerScott Lamb <slamb@slamb.org>
Wed, 7 Nov 2007 02:50:58 +0000 (02:50 +0000)
doc/tinc.texi
doc/tincctl.8.in
doc/tincd.8.in
src/control.c
src/control_common.h
src/net.c
src/net.h
src/tincctl.c

index b3f570c69d03b263b9ee6ceb5d69eed9a370a46b..9baf177467b0157dbd3308c72d09b750ac6eff2a 100644 (file)
@@ -1553,13 +1553,6 @@ You can also send the following signals to a running tincd process:
 @c from the manpage
 @table @samp
 
 @c from the manpage
 @table @samp
 
-@item ALRM
-Forces tinc to try to connect to all uplinks immediately.
-Usually tinc attempts to do this itself,
-but increases the time it waits between the attempts each time it failed,
-and if tinc didn't succeed to connect to an uplink the first time after it started,
-it defaults to the maximum time of 15 minutes.
-
 @item HUP
 Partially rereads configuration files.
 Connections to hosts whose host config file are removed are closed.
 @item HUP
 Partially rereads configuration files.
 Connections to hosts whose host config file are removed are closed.
@@ -1853,6 +1846,13 @@ Purges all information remembered about unreachable nodes.
 @item debug @var{level}
 Sets debug level to @var{level}.
 
 @item debug @var{level}
 Sets debug level to @var{level}.
 
+@item retry
+Forces tinc to try to connect to all uplinks immediately.
+Usually tinc attempts to do this itself,
+but increases the time it waits between the attempts each time it failed,
+and if tinc didn't succeed to connect to an uplink the first time after it started,
+it defaults to the maximum time of 15 minutes.
+
 @end table
 
 
 @end table
 
 
index 623c908b6c5447e13f0c66e99f75d788ce717668..899b066743c7e0e6e040011dfe09970aba1408b8 100644 (file)
@@ -81,6 +81,18 @@ Purges all information remembered about unreachable nodes.
 .It debug Ar N
 Sets debug level to
 .Ar N .
 .It debug Ar N
 Sets debug level to
 .Ar N .
+.It retry
+Forces
+.Xr tincd 8
+to try to connect to all uplinks immediately.
+Usually
+.Xr tincd 8
+attempts to do this itself,
+but increases the time it waits between the attempts each time it failed,
+and if
+.Xr tincd 8
+didn't succeed to connect to an uplink the first time after it started,
+it defaults to the maximum time of 15 minutes.
 .El
 .Sh BUGS
 The "start", "restart", and "reload" commands are not yet implemented.
 .El
 .Sh BUGS
 The "start", "restart", and "reload" commands are not yet implemented.
index b3142e829006cba0253aac93d2ac184eac95fd43..e4bbaeb7bfd04b32f94284a82e9fa03eb2d8d0f1 100644 (file)
@@ -77,18 +77,6 @@ Output version information and exit.
 .El
 .Sh SIGNALS
 .Bl -tag -width indent
 .El
 .Sh SIGNALS
 .Bl -tag -width indent
-.It ALRM
-Forces
-.Nm
-to try to connect to all uplinks immediately.
-Usually
-.Nm
-attempts to do this itself,
-but increases the time it waits between the attempts each time it failed,
-and if
-.Nm
-didn't succeed to connect to an uplink the first time after it started,
-it defaults to the maximum time of 15 minutes.
 .It HUP
 Partially rereads configuration files.
 Connections to hosts whose host config file are removed are closed.
 .It HUP
 Partially rereads configuration files.
 Connections to hosts whose host config file are removed are closed.
index 3e57f5512f4f759b1043ea23d0634232b7c0cdef..6a39e02eeca2395aca9f9f2406d394c86fa7cf6d 100644 (file)
@@ -124,6 +124,12 @@ static void handle_control_data(struct bufferevent *event, void *data) {
                goto respond;
        }
 
                goto respond;
        }
 
+       if(req.type == REQ_RETRY) {
+               logger(LOG_NOTICE, _("Got '%s' command"), "retry");
+               retry();
+               goto respond;
+       }
+
        logger(LOG_DEBUG, _("Malformed control command received"));
        res.res_errno = EINVAL;
 
        logger(LOG_DEBUG, _("Malformed control command received"));
        res.res_errno = EINVAL;
 
index 2b7795562299ae91da1029c14132bb0ed580da4f..09758266563fc3275c158329404fb6107c00dfbc 100644 (file)
@@ -33,6 +33,7 @@ enum request_type {
        REQ_DUMP_GRAPH,
        REQ_PURGE,
        REQ_SET_DEBUG,
        REQ_DUMP_GRAPH,
        REQ_PURGE,
        REQ_SET_DEBUG,
+       REQ_RETRY,
 };
 
 #define TINC_CTL_VERSION_CURRENT 0
 };
 
 #define TINC_CTL_VERSION_CURRENT 0
index aaa035feadce092ca19b4746649e780815cd2688..4a680d8e51ebd2ba40dc29418e5fdccfddac9f71 100644 (file)
--- a/src/net.c
+++ b/src/net.c
@@ -280,9 +280,7 @@ static void sighup_handler(int signal, short events, void *data) {
        try_outgoing_connections();
 }
 
        try_outgoing_connections();
 }
 
-static void sigalrm_handler(int signal, short events, void *data) {
-       logger(LOG_NOTICE, _("Got %s signal"), strsignal(signal));
-
+void retry(void) {
        connection_t *c;
        splay_node_t *node;
 
        connection_t *c;
        splay_node_t *node;
 
@@ -308,7 +306,6 @@ int main_loop(void) {
        struct event sighup_event;
        struct event sigterm_event;
        struct event sigquit_event;
        struct event sighup_event;
        struct event sigterm_event;
        struct event sigquit_event;
-       struct event sigalrm_event;
 
        cp();
 
 
        cp();
 
@@ -320,8 +317,6 @@ int main_loop(void) {
        signal_add(&sigterm_event, NULL);
        signal_set(&sigquit_event, SIGQUIT, sigterm_handler, NULL);
        signal_add(&sigquit_event, NULL);
        signal_add(&sigterm_event, NULL);
        signal_set(&sigquit_event, SIGQUIT, sigterm_handler, NULL);
        signal_add(&sigquit_event, NULL);
-       signal_set(&sigalrm_event, SIGALRM, sigalrm_handler, NULL);
-       signal_add(&sigalrm_event, NULL);
 
        if(event_loop(0) < 0) {
                logger(LOG_ERR, _("Error while waiting for input: %s"), strerror(errno));
 
        if(event_loop(0) < 0) {
                logger(LOG_ERR, _("Error while waiting for input: %s"), strerror(errno));
@@ -331,7 +326,6 @@ int main_loop(void) {
        signal_del(&sighup_event);
        signal_del(&sigterm_event);
        signal_del(&sigquit_event);
        signal_del(&sighup_event);
        signal_del(&sigterm_event);
        signal_del(&sigquit_event);
-       signal_del(&sigalrm_event);
        event_del(&timeout_event);
 
        return 0;
        event_del(&timeout_event);
 
        return 0;
index fd14c37b37148f7a1c621b43e20b7295925622d3..b8e9e37750ddeae705204d48961d5f8fd24a6b51 100644 (file)
--- a/src/net.h
+++ b/src/net.h
@@ -156,6 +156,7 @@ extern void handle_device_data(int, short, void *);
 extern void handle_meta_connection_data(int, short, void *);
 extern void regenerate_key();
 extern void purge(void);
 extern void handle_meta_connection_data(int, short, void *);
 extern void regenerate_key();
 extern void purge(void);
+extern void retry(void);
 
 #ifndef HAVE_MINGW
 #define closesocket(s) close(s)
 
 #ifndef HAVE_MINGW
 #define closesocket(s) close(s)
index bff122b0efc5518f0403272a9226f153b73bceb3..9b16a7b7a33beba1d3468d5bb5a7b56b8e36e7c5 100644 (file)
@@ -91,6 +91,7 @@ static void usage(bool status) {
                                "    graph                    - graph of the VPN in dotty format\n"
                                "  purge                      Purge unreachable nodes\n"
                                "  debug N                    Set debug level\n"
                                "    graph                    - graph of the VPN in dotty format\n"
                                "  purge                      Purge unreachable nodes\n"
                                "  debug N                    Set debug level\n"
+                               "  retry                      Retry all outgoing connections\n"
                                "\n"));
                printf(_("Report bugs to tinc@tinc-vpn.org.\n"));
        }
                                "\n"));
                printf(_("Report bugs to tinc@tinc-vpn.org.\n"));
        }
@@ -596,6 +597,10 @@ int main(int argc, char *argv[], char *envp[]) {
                                                                           sizeof(debuglevel)) != -1;
        }
 
                                                                           sizeof(debuglevel)) != -1;
        }
 
+       if(!strcasecmp(argv[optind], "retry")) {
+               return send_ctl_request_cooked(fd, REQ_RETRY, NULL, 0) != -1;
+       }
+
        fprintf(stderr, _("Unknown command `%s'.\n"), argv[optind]);
        usage(true);
        
        fprintf(stderr, _("Unknown command `%s'.\n"), argv[optind]);
        usage(true);