X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fnet.c;h=cb6ed4996638b35899a5f51b0cff48a4f9d17c51;hb=4bdf0e80ee4cd0d40eb6522dab05df9346a5b3d0;hp=aaa035feadce092ca19b4746649e780815cd2688;hpb=a62a6825a8a69e279ee0688a4cd9e51fbc52054b;p=tinc diff --git a/src/net.c b/src/net.c index aaa035fe..cb6ed499 100644 --- a/src/net.c +++ b/src/net.c @@ -1,7 +1,7 @@ /* net.c -- most of the network code Copyright (C) 1998-2005 Ivo Timmermans, - 2000-2006 Guus Sliepen + 2000-2009 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -203,7 +203,7 @@ static void timeout_handler(int fd, short events, void *event) { void handle_meta_connection_data(int fd, short events, void *data) { connection_t *c = data; int result; - socklen_t len = sizeof(result); + socklen_t len = sizeof result; if(c->status.connecting) { c->status.connecting = false; @@ -234,13 +234,16 @@ static void sigterm_handler(int signal, short events, void *data) { } static void sighup_handler(int signal, short events, void *data) { + logger(LOG_NOTICE, _("Got %s signal"), strsignal(signal)); + reload_configuration(); +} + +int reload_configuration(void) { connection_t *c; splay_node_t *node, *next; char *fname; struct stat s; static time_t last_config_check = 0; - - logger(LOG_NOTICE, _("Got %s signal"), strsignal(signal)); /* Reread our own configuration file */ @@ -250,7 +253,7 @@ static void sighup_handler(int signal, short events, void *data) { if(!read_server_config()) { logger(LOG_ERR, _("Unable to reread configuration file, exitting.")); event_loopexit(NULL); - return; + return EINVAL; } /* Close connections to hosts that have a changed or deleted host config file */ @@ -267,7 +270,7 @@ static void sighup_handler(int signal, short events, void *data) { c->outgoing = NULL; } - asprintf(&fname, "%s/hosts/%s", confbase, c->name); + xasprintf(&fname, "%s/hosts/%s", confbase, c->name); if(stat(fname, &s) || s.st_mtime > last_config_check) terminate_connection(c, c->status.active); free(fname); @@ -278,11 +281,11 @@ static void sighup_handler(int signal, short events, void *data) { /* Try to make outgoing connections */ try_outgoing_connections(); -} -static void sigalrm_handler(int signal, short events, void *data) { - logger(LOG_NOTICE, _("Got %s signal"), strsignal(signal)); + return 0; +} +void retry(void) { connection_t *c; splay_node_t *node; @@ -308,7 +311,6 @@ int main_loop(void) { struct event sighup_event; struct event sigterm_event; struct event sigquit_event; - struct event sigalrm_event; cp(); @@ -320,8 +322,6 @@ int main_loop(void) { 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)); @@ -331,7 +331,6 @@ int main_loop(void) { signal_del(&sighup_event); signal_del(&sigterm_event); signal_del(&sigquit_event); - signal_del(&sigalrm_event); event_del(&timeout_event); return 0;