From 125c4978812cffa5154ce5378a276f43f78417d8 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Thu, 1 Mar 2001 21:32:04 +0000 Subject: [PATCH] Various small fixes. --- src/net.c | 22 +++++++++++++++------- src/process.c | 6 +++--- src/process.h | 4 +++- src/tincd.c | 10 +++------- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/net.c b/src/net.c index 5c59c6fa..106549e0 100644 --- a/src/net.c +++ b/src/net.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: net.c,v 1.35.4.100 2001/02/27 16:37:25 guus Exp $ + $Id: net.c,v 1.35.4.101 2001/03/01 21:32:01 guus Exp $ */ #include "config.h" @@ -84,6 +84,7 @@ #include "process.h" #include "protocol.h" #include "subnet.h" +#include "process.h" #include "system.h" @@ -929,11 +930,17 @@ cp cfg = get_config_val(upstreamcfg, config_connectto); /* Or else we try the next ConnectTo line */ } - signal(SIGALRM, sigalrm_handler); - upstreamcfg = config; - seconds_till_retry = MAXTIMEOUT; - syslog(LOG_NOTICE, _("Trying to re-establish outgoing connection in %d seconds"), seconds_till_retry); - alarm(seconds_till_retry); + if(do_detach) + { + signal(SIGALRM, sigalrm_handler); + upstreamcfg = config; + seconds_till_retry = MAXTIMEOUT; + syslog(LOG_NOTICE, _("Trying to re-establish outgoing connection in %d seconds"), seconds_till_retry); + alarm(seconds_till_retry); + } + else + return -1; + cp return 0; } @@ -949,6 +956,7 @@ cp for(node = connection_tree->head; node; node = node->next) { p = (connection_t *)node->data; + p->status.outgoing = 0; p->status.active = 0; terminate_connection(p); } @@ -1349,7 +1357,7 @@ cp if(read_server_config()) { syslog(LOG_ERR, _("Unable to reread configuration file, exiting")); - exit(0); + exit(1); } sleep(5); diff --git a/src/process.c b/src/process.c index 6158fbab..35793a27 100644 --- a/src/process.c +++ b/src/process.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: process.c,v 1.1.2.20 2001/01/07 17:09:02 guus Exp $ + $Id: process.c,v 1.1.2.21 2001/03/01 21:32:04 guus Exp $ */ #include "config.h" @@ -221,7 +221,7 @@ cp /* No return on success */ if(errno != ENOENT) /* Ignore if the file does not exist */ - exit(-1); /* Some error while trying execl(). */ + exit(1); /* Some error while trying execl(). */ else exit(0); } @@ -309,7 +309,7 @@ sigsegv_square(int a, siginfo_t *info, void *b) { syslog(LOG_ERR, _("Got another SEGV signal: not restarting")); cp_trace(); - exit(0); + exit(1); } RETSIGTYPE diff --git a/src/process.h b/src/process.h index ed834f0c..9fb13c7c 100644 --- a/src/process.h +++ b/src/process.h @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: process.h,v 1.1.2.7 2001/01/07 17:09:02 guus Exp $ + $Id: process.h,v 1.1.2.8 2001/03/01 21:32:04 guus Exp $ */ #ifndef __TINC_PROCESS_H__ @@ -25,6 +25,8 @@ #include "config.h" +extern int do_detach; + extern void setup_signals(void); extern int execute_script(const char *); extern int detach(void); diff --git a/src/tincd.c b/src/tincd.c index 0495779a..318f7594 100644 --- a/src/tincd.c +++ b/src/tincd.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: tincd.c,v 1.10.4.44 2001/02/27 16:37:31 guus Exp $ + $Id: tincd.c,v 1.10.4.45 2001/03/01 21:32:04 guus Exp $ */ #include "config.h" @@ -88,9 +88,6 @@ static int show_version; /* If nonzero, it will attempt to kill a running tincd and exit. */ static int kill_tincd = 0; -/* If zero, don't detach from the terminal. */ -extern int do_detach; - /* If nonzero, generate public/private keypair for this host/net. */ static int generate_keys = 0; @@ -356,7 +353,7 @@ cp exit(kill_other()); if(read_server_config()) - return 1; + exit(1); cp if(detach()) exit(0); @@ -383,8 +380,7 @@ cp else { syslog(LOG_ERR, _("Not restarting.")); - exit(0); + exit(1); } } } - -- 2.20.1