X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fnet.c;h=87deb97b60d669bf19897a54b6dbd275de644f72;hb=f38b9f67f87c364c50fd21d48aa85f946675b4e2;hp=415b0cffc5603419ea17b51b0f3d64bcdc5f6ec6;hpb=084ba04f51441098c55d3bd21b11bbe368e7b52e;p=meshlink diff --git a/src/net.c b/src/net.c index 415b0cff..87deb97b 100644 --- a/src/net.c +++ b/src/net.c @@ -1,9 +1,6 @@ /* net.c -- most of the network code - Copyright (C) 1998-2005 Ivo Timmermans, - 2000-2013 Guus Sliepen - 2006 Scott Lamb - 2011 Loïc Grenié + Copyright (C) 2014 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 @@ -28,7 +25,6 @@ #include "graph.h" #include "logger.h" #include "meta.h" -#include "names.h" #include "net.h" #include "netutl.h" #include "protocol.h" @@ -41,6 +37,9 @@ time_t last_config_check = 0; static timeout_t pingtimer; static timeout_t periodictimer; +//TODO: move this to a better place +char *confbase; + /* Purge edges of unreachable nodes. Use carefully. */ // TODO: remove @@ -54,8 +53,7 @@ void purge(void) { logger(DEBUG_SCARY_THINGS, LOG_DEBUG, "Purging node %s (%s)", n->name, n->hostname); for splay_each(edge_t, e, n->edge_tree) { - if(!tunnelserver) - send_del_edge(everyone, e); + send_del_edge(everyone, e); edge_del(e); } } @@ -88,7 +86,7 @@ void terminate_connection(connection_t *c, bool report) { c->node->connection = NULL; if(c->edge) { - if(report && !tunnelserver) + if(report) send_del_edge(everyone, c->edge); edge_del(c->edge); @@ -104,8 +102,7 @@ void terminate_connection(connection_t *c, bool report) { edge_t *e; e = lookup_edge(c->node, myself); if(e) { - if(!tunnelserver) - send_del_edge(everyone, e); + send_del_edge(everyone, e); edge_del(e); } } @@ -280,25 +277,6 @@ void handle_meta_connection_data(connection_t *c) { } } -#ifndef HAVE_MINGW -static void sigterm_handler(void *data) { - logger(DEBUG_ALWAYS, LOG_NOTICE, "Got %s signal", strsignal(((signal_t *)data)->signum)); - event_exit(); -} - -static void sighup_handler(void *data) { - logger(DEBUG_ALWAYS, LOG_NOTICE, "Got %s signal", strsignal(((signal_t *)data)->signum)); - reopenlogger(); - if(reload_configuration()) - exit(1); -} - -static void sigalrm_handler(void *data) { - logger(DEBUG_ALWAYS, LOG_NOTICE, "Got %s signal", strsignal(((signal_t *)data)->signum)); - retry(); -} -#endif - int reload_configuration(void) { char *fname = NULL; @@ -312,8 +290,6 @@ int reload_configuration(void) { return EINVAL; } - read_config_options(config_tree, NULL); - xasprintf(&fname, "%s" SLASH "hosts" SLASH "%s", confbase, myself->name); read_config_file(config_tree, fname); free(fname); @@ -368,33 +344,11 @@ int main_loop(void) { timeout_add(&pingtimer, timeout_handler, &pingtimer, &(struct timeval){pingtimeout, rand() % 100000}); timeout_add(&periodictimer, periodic_handler, &periodictimer, &(struct timeval){pingtimeout, rand() % 100000}); -#ifndef HAVE_MINGW - signal_t sighup = {0}; - signal_t sigterm = {0}; - signal_t sigquit = {0}; - signal_t sigint = {0}; - signal_t sigalrm = {0}; - - signal_add(&sighup, sighup_handler, &sighup, SIGHUP); - signal_add(&sigterm, sigterm_handler, &sigterm, SIGTERM); - signal_add(&sigquit, sigterm_handler, &sigquit, SIGQUIT); - signal_add(&sigint, sigterm_handler, &sigint, SIGINT); - signal_add(&sigalrm, sigalrm_handler, &sigalrm, SIGALRM); -#endif - if(!event_loop()) { logger(DEBUG_ALWAYS, LOG_ERR, "Error while waiting for input: %s", strerror(errno)); return 1; } -#ifndef HAVE_MINGW - signal_del(&sighup); - signal_del(&sigterm); - signal_del(&sigquit); - signal_del(&sigint); - signal_del(&sigalrm); -#endif - timeout_del(&periodictimer); timeout_del(&pingtimer);