- Removed segfault bug in conf.c (must have been there for ages!)
- Made main_loop() signal proof - #defined MAXTIMEOUT (15 minutes) - If something really really bad happens, close all connections, wait for MAXTIMEOUT seconds, and then restart tinc
This commit is contained in:
parent
0f9ad1f047
commit
24874d0806
5 changed files with 116 additions and 113 deletions
20
src/conf.c
20
src/conf.c
|
|
@ -19,7 +19,7 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
$Id: conf.c,v 1.9.4.4 2000/06/29 19:47:02 guus Exp $
|
||||
$Id: conf.c,v 1.9.4.5 2000/06/30 11:45:14 guus Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
|
@ -109,6 +109,8 @@ cp
|
|||
p->data.val = 0;
|
||||
}
|
||||
|
||||
p->argtype = argtype;
|
||||
|
||||
if(p->data.val)
|
||||
{
|
||||
if(*cfg)
|
||||
|
|
@ -195,6 +197,7 @@ cp
|
|||
config = cfg;
|
||||
}
|
||||
cp
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -203,6 +206,7 @@ cp
|
|||
int
|
||||
read_config_file(const char *fname)
|
||||
{
|
||||
int err;
|
||||
FILE *fp;
|
||||
cp
|
||||
if((fp = fopen (fname, "r")) == NULL)
|
||||
|
|
@ -211,12 +215,10 @@ cp
|
|||
return 1;
|
||||
}
|
||||
|
||||
if(readconfig(fname, fp))
|
||||
return -1;
|
||||
|
||||
err = readconfig(fname, fp);
|
||||
fclose (fp);
|
||||
cp
|
||||
return 0;
|
||||
return err;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -260,11 +262,13 @@ void clear_config()
|
|||
{
|
||||
config_t *p, *next;
|
||||
cp
|
||||
for(p = config; p; p = next)
|
||||
for(p = config; p != NULL; p = next)
|
||||
{
|
||||
next = p->next;
|
||||
if(p->data.ptr)
|
||||
free(p->data.ptr);
|
||||
if(p->data.ptr && (p->argtype == TYPE_NAME))
|
||||
{
|
||||
free(p->data.ptr);
|
||||
}
|
||||
free(p);
|
||||
}
|
||||
config = NULL;
|
||||
|
|
|
|||
|
|
@ -17,12 +17,14 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
$Id: conf.h,v 1.6.4.4 2000/06/29 19:47:03 guus Exp $
|
||||
$Id: conf.h,v 1.6.4.5 2000/06/30 11:45:14 guus Exp $
|
||||
*/
|
||||
|
||||
#ifndef __TINC_CONF_H__
|
||||
#define __TINC_CONF_H__
|
||||
|
||||
#define MAXTIMEOUT 900 /* Maximum timeout value for retries. Should this be a configuration option? */
|
||||
|
||||
typedef struct ip_mask_t {
|
||||
unsigned long ip;
|
||||
unsigned long mask;
|
||||
|
|
@ -46,12 +48,13 @@ typedef enum which_t {
|
|||
keyexpire,
|
||||
vpnmask,
|
||||
resolve_dns,
|
||||
indirectdata
|
||||
indirectdata,
|
||||
} which_t;
|
||||
|
||||
typedef struct config_t {
|
||||
struct config_t *next;
|
||||
which_t which;
|
||||
int argtype;
|
||||
data_t data;
|
||||
} config_t;
|
||||
|
||||
|
|
|
|||
35
src/net.c
35
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.15 2000/06/29 19:47:03 guus Exp $
|
||||
$Id: net.c,v 1.35.4.16 2000/06/30 11:45:14 guus Exp $
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
|
@ -636,11 +636,11 @@ cp
|
|||
signal(SIGALRM, sigalrm_handler);
|
||||
upstreamindex = 0;
|
||||
seconds_till_retry += 5;
|
||||
if(seconds_till_retry>300) /* Don't wait more than 5 minutes. */
|
||||
seconds_till_retry = 300;
|
||||
alarm(seconds_till_retry);
|
||||
if(seconds_till_retry > MAXTIMEOUT) /* Don't wait more than MAXTIMEOUT seconds. */
|
||||
seconds_till_retry = MAXTIMEOUT;
|
||||
syslog(LOG_ERR, _("Still failed to connect to other, will retry in %d seconds"),
|
||||
seconds_till_retry);
|
||||
alarm(seconds_till_retry);
|
||||
cp
|
||||
}
|
||||
|
||||
|
|
@ -675,9 +675,9 @@ cp
|
|||
|
||||
signal(SIGALRM, sigalrm_handler);
|
||||
upstreamindex = 0;
|
||||
seconds_till_retry = 300;
|
||||
seconds_till_retry = MAXTIMEOUT;
|
||||
syslog(LOG_NOTICE, _("Trying to re-establish outgoing connection in %d seconds"), seconds_till_retry);
|
||||
alarm(seconds_till_retry);
|
||||
syslog(LOG_NOTICE, _("Trying to re-establish outgoing connection in 5 minutes"));
|
||||
cp
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -779,7 +779,6 @@ cp
|
|||
return NULL;
|
||||
}
|
||||
|
||||
p->vpn_hostname = _("unknown");
|
||||
p->real_ip = ntohl(ci.sin_addr.s_addr);
|
||||
p->real_hostname = hostlookup(ci.sin_addr.s_addr);
|
||||
p->meta_socket = sfd;
|
||||
|
|
@ -1244,19 +1243,15 @@ cp
|
|||
|
||||
if(sighup)
|
||||
{
|
||||
sighup = 0;
|
||||
close_network_connections();
|
||||
clear_config();
|
||||
if(read_config_file(configfilename))
|
||||
{
|
||||
syslog(LOG_ERR, _("Unable to reread configuration file, exitting"));
|
||||
syslog(LOG_ERR, _("Unable to reread configuration file, exiting"));
|
||||
exit(0);
|
||||
}
|
||||
if(setup_network_connections())
|
||||
{
|
||||
syslog(LOG_ERR, _("Unable to restart, exitting"));
|
||||
exit(0);
|
||||
}
|
||||
sighup = 0;
|
||||
setup_network_connections();
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -1265,14 +1260,16 @@ cp
|
|||
{
|
||||
check_dead_connections();
|
||||
last_ping_check = time(NULL);
|
||||
continue;
|
||||
}
|
||||
|
||||
check_network_activity(&fset);
|
||||
if(r > 0)
|
||||
{
|
||||
check_network_activity(&fset);
|
||||
|
||||
/* local tap data */
|
||||
if(FD_ISSET(tap_fd, &fset))
|
||||
handle_tap_input();
|
||||
/* local tap data */
|
||||
if(FD_ISSET(tap_fd, &fset))
|
||||
handle_tap_input();
|
||||
}
|
||||
}
|
||||
cp
|
||||
}
|
||||
|
|
|
|||
18
src/tincd.c
18
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.5 2000/06/29 19:47:04 guus Exp $
|
||||
$Id: tincd.c,v 1.10.4.6 2000/06/30 11:45:16 guus Exp $
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
|
@ -374,13 +374,17 @@ main(int argc, char **argv, char **envp)
|
|||
if(security_init())
|
||||
return 1;
|
||||
|
||||
if(setup_network_connections())
|
||||
cleanup_and_exit(1);
|
||||
for(;;)
|
||||
{
|
||||
setup_network_connections();
|
||||
|
||||
main_loop();
|
||||
main_loop();
|
||||
|
||||
cleanup_and_exit(1);
|
||||
return 1;
|
||||
cleanup_and_exit(1);
|
||||
|
||||
syslog(LOG_ERR, _("Unrecoverable error, restarting in %d seconds!"), MAXTIMEOUT);
|
||||
sleep(MAXTIMEOUT);
|
||||
}
|
||||
}
|
||||
|
||||
RETSIGTYPE
|
||||
|
|
@ -433,7 +437,7 @@ RETSIGTYPE
|
|||
sigint_handler(int a)
|
||||
{
|
||||
if(debug_lvl > 0)
|
||||
syslog(LOG_NOTICE, _("Got INT signal, exitting"));
|
||||
syslog(LOG_NOTICE, _("Got INT signal, exiting"));
|
||||
cleanup_and_exit(0);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue