X-Git-Url: https://tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fnet.c;h=3f17083c192dec33ceb2fb5481513294263d6b8f;hp=7f1f77b38b192ea2e14db8b1a5afe300a6333371;hb=e00b44cb98e4d50a0d426048ba01dbd80bcb5941;hpb=4c85542894f7fca823b119b05e07179deb24229a diff --git a/src/net.c b/src/net.c index 7f1f77b3..3f17083c 100644 --- a/src/net.c +++ b/src/net.c @@ -2,6 +2,7 @@ net.c -- most of the network code Copyright (C) 1998-2005 Ivo Timmermans, 2000-2009 Guus Sliepen + 2006 Scott Lamb 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 @@ -302,7 +303,7 @@ static void check_network_activity(fd_set * readset, fd_set * writeset) { else { ifdebug(CONNECTIONS) logger(LOG_DEBUG, "Error while connecting to %s (%s): %s", - c->name, c->hostname, strerror(result)); + c->name, c->hostname, sockstrerror(result)); closesocket(c->socket); do_outgoing_connection(c); continue; @@ -368,9 +369,8 @@ int main_loop(void) { #endif if(r < 0) { - if(errno != EINTR && errno != EAGAIN) { - logger(LOG_ERR, "Error while waiting for input: %s", - strerror(errno)); + if(!sockwouldblock(sockerrno)) { + logger(LOG_ERR, "Error while waiting for input: %s", sockstrerror(sockerrno)); dump_connections(); return 1; } @@ -430,7 +430,7 @@ int main_loop(void) { if(sighup) { connection_t *c; - avl_node_t *node; + avl_node_t *node, *next; char *fname; struct stat s; @@ -446,6 +446,31 @@ int main_loop(void) { return 1; } + /* Cancel non-active outgoing connections */ + + for(node = connection_tree->head; node; node = next) { + next = node->next; + c = node->data; + + c->outgoing = NULL; + + if(c->status.connecting) { + terminate_connection(c, false); + connection_del(c); + } + } + + /* Wipe list of outgoing connections */ + + for(list_node_t *node = outgoing_list->head; node; node = node->next) { + outgoing_t *outgoing = node->data; + + if(outgoing->event) + event_del(outgoing->event); + } + + list_delete_list(outgoing_list); + /* Close connections to hosts that have a changed or deleted host config file */ for(node = connection_tree->head; node; node = node->next) {