From 3b237afbda86bc95703ed25386cc9a26695d4602 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Sat, 25 Jun 2011 20:20:07 +0200 Subject: [PATCH] Re-add support for SIGALRM. --- doc/tinc.texi | 7 +++++++ doc/tincd.8.in | 21 ++++++++++++--------- src/net.c | 27 +++++++++++++++++---------- src/process.c | 1 - 4 files changed, 36 insertions(+), 20 deletions(-) diff --git a/doc/tinc.texi b/doc/tinc.texi index 7fa4719e..daf807b8 100644 --- a/doc/tinc.texi +++ b/doc/tinc.texi @@ -1632,6 +1632,13 @@ You can also send the following signals to a running tincd process: @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. diff --git a/doc/tincd.8.in b/doc/tincd.8.in index bb560256..ea722042 100644 --- a/doc/tincd.8.in +++ b/doc/tincd.8.in @@ -98,6 +98,18 @@ Output version information and exit. .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. @@ -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. -.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. diff --git a/src/net.c b/src/net.c index aae73969..7ce4f318 100644 --- a/src/net.c +++ b/src/net.c @@ -248,6 +248,11 @@ static void sighup_handler(int signal, short events, void *data) { 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; @@ -349,24 +354,24 @@ void retry(void) { */ 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}); -#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); -#endif -#ifdef SIGTERM 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(&sigalrm_event, SIGALRM, sigalrm_handler, NULL); + signal_add(&sigalrm_event, NULL); #endif if(event_loop(0) < 0) { @@ -374,12 +379,14 @@ int main_loop(void) { return 1; } +#ifndef HAVE_MINGW 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; } diff --git a/src/process.c b/src/process.c index ee5fce97..0584da67 100644 --- a/src/process.c +++ b/src/process.c @@ -224,7 +224,6 @@ bool init_service(void) { */ bool detach(void) { #ifndef HAVE_MINGW - signal(SIGALRM, SIG_IGN); signal(SIGPIPE, SIG_IGN); signal(SIGUSR1, SIG_IGN); signal(SIGUSR2, SIG_IGN); -- 2.39.5