Re-add support for SIGALRM.
authorGuus Sliepen <guus@tinc-vpn.org>
Sat, 25 Jun 2011 18:20:07 +0000 (20:20 +0200)
committerGuus Sliepen <guus@tinc-vpn.org>
Sat, 25 Jun 2011 18:20:07 +0000 (20:20 +0200)
doc/tinc.texi
doc/tincd.8.in
src/net.c
src/process.c

index 7fa4719..daf807b 100644 (file)
@@ -1632,6 +1632,13 @@ 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.
index bb56025..ea72204 100644 (file)
@@ -98,6 +98,18 @@ 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.
@@ -108,15 +120,6 @@ If the
 .Fl -logfile
 option is used, this will also close and reopen the log file,
 useful when log rotation is used.
 .Fl -logfile
 option is used, this will also close and reopen the log file,
 useful when log rotation is used.
-.It INT
-Temporarily increases debug level to 5.
-Send this signal again to revert to the original level.
-.It USR1
-Dumps the connection list to syslog.
-.It USR2
-Dumps virtual network device statistics, all known nodes, edges and subnets to syslog.
-.It WINCH
-Purges all information remembered about unreachable nodes.
 .El
 .Sh DEBUG LEVELS
 The tinc daemon can send a lot of messages to the syslog.
 .El
 .Sh DEBUG LEVELS
 The tinc daemon can send a lot of messages to the syslog.
index aae7396..7ce4f31 100644 (file)
--- a/src/net.c
+++ b/src/net.c
@@ -248,6 +248,11 @@ static void sighup_handler(int signal, short events, void *data) {
        reload_configuration();
 }
 
        reload_configuration();
 }
 
+static void sigalrm_handler(int signal, short events, void *data) {
+       logger(LOG_NOTICE, "Got %s signal", strsignal(signal));
+       retry();
+}
+
 int reload_configuration(void) {
        connection_t *c;
        splay_node_t *node, *next;
 int reload_configuration(void) {
        connection_t *c;
        splay_node_t *node, *next;
@@ -349,24 +354,24 @@ void retry(void) {
 */
 int main_loop(void) {
        struct event timeout_event;
 */
 int main_loop(void) {
        struct event timeout_event;
-       struct event sighup_event;
-       struct event sigterm_event;
-       struct event sigquit_event;
 
        timeout_set(&timeout_event, timeout_handler, &timeout_event);
        event_add(&timeout_event, &(struct timeval){pingtimeout, 0});
 
 
        timeout_set(&timeout_event, timeout_handler, &timeout_event);
        event_add(&timeout_event, &(struct timeval){pingtimeout, 0});
 
-#ifdef SIGHUP
+#ifndef HAVE_MINGW
+       struct event sighup_event;
+       struct event sigterm_event;
+       struct event sigquit_event;
+       struct event sigalrm_event;
+
        signal_set(&sighup_event, SIGHUP, sighup_handler, NULL);
        signal_add(&sighup_event, NULL);
        signal_set(&sighup_event, SIGHUP, sighup_handler, NULL);
        signal_add(&sighup_event, NULL);
-#endif
-#ifdef SIGTERM
        signal_set(&sigterm_event, SIGTERM, sigterm_handler, NULL);
        signal_add(&sigterm_event, NULL);
        signal_set(&sigterm_event, SIGTERM, sigterm_handler, NULL);
        signal_add(&sigterm_event, NULL);
-#endif
-#ifdef SIGQUIT
        signal_set(&sigquit_event, SIGQUIT, sigterm_handler, NULL);
        signal_add(&sigquit_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);
 #endif
 
        if(event_loop(0) < 0) {
 #endif
 
        if(event_loop(0) < 0) {
@@ -374,12 +379,14 @@ int main_loop(void) {
                return 1;
        }
 
                return 1;
        }
 
+#ifndef HAVE_MINGW
        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);
+#endif
 
 
-       if(timeout_initialized(&timeout_event))
-               event_del(&timeout_event);
+       event_del(&timeout_event);
 
        return 0;
 }
 
        return 0;
 }
index ee5fce9..0584da6 100644 (file)
@@ -224,7 +224,6 @@ bool init_service(void) {
 */
 bool detach(void) {
 #ifndef HAVE_MINGW
 */
 bool detach(void) {
 #ifndef HAVE_MINGW
-       signal(SIGALRM, SIG_IGN);
        signal(SIGPIPE, SIG_IGN);
        signal(SIGUSR1, SIG_IGN);
        signal(SIGUSR2, SIG_IGN);
        signal(SIGPIPE, SIG_IGN);
        signal(SIGUSR1, SIG_IGN);
        signal(SIGUSR2, SIG_IGN);