X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fgraph.c;h=5a0aab0ba7bd04979198492ef7ab3854b251484c;hb=108b238915c5f58b3d94ab433dc5d04e064c2b11;hp=4e060b7ffa9c647cd4cc3103085e3e542ddf3ef7;hpb=5a132550deb58473285e5f91705d286aef47be71;p=tinc diff --git a/src/graph.c b/src/graph.c index 4e060b7f..5a0aab0b 100644 --- a/src/graph.c +++ b/src/graph.c @@ -13,11 +13,9 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id$ + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ /* We need to generate two trees from the graph: @@ -57,6 +55,7 @@ #include "process.h" #include "subnet.h" #include "utils.h" +#include "xalloc.h" /* Implementation of Kruskal's algorithm. Running time: O(E) @@ -69,8 +68,6 @@ void mst_kruskal(void) { node_t *n; connection_t *c; - cp(); - /* Clear MST status on connections */ for(node = connection_tree->head; node; node = node->next) { @@ -122,8 +119,6 @@ void sssp_dijkstra(void) { list_node_t *lnode, *nnode; bool indirect; - cp(); - todo_list = list_alloc(NULL); ifdebug(SCARY_THINGS) logger(LOG_DEBUG, "Running Dijkstra's algorithm:"); @@ -248,8 +243,6 @@ void sssp_bfs(void) { list_node_t *from, *todonext; bool indirect; - cp(); - todo_list = list_alloc(NULL); /* Clear visited status on nodes */ @@ -343,10 +336,10 @@ void check_reachability() { n->status.reachable = !n->status.reachable; if(n->status.reachable) { - ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Node %s (%s) became reachable"), + ifdebug(TRAFFIC) logger(LOG_DEBUG, "Node %s (%s) became reachable", n->name, n->hostname); } else { - ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Node %s (%s) became unreachable"), + ifdebug(TRAFFIC) logger(LOG_DEBUG, "Node %s (%s) became unreachable", n->name, n->hostname); } @@ -359,18 +352,20 @@ void check_reachability() { n->minmtu = 0; n->mtuprobes = 0; - asprintf(&envp[0], "NETNAME=%s", netname ? : ""); - asprintf(&envp[1], "DEVICE=%s", device ? : ""); - asprintf(&envp[2], "INTERFACE=%s", iface ? : ""); - asprintf(&envp[3], "NODE=%s", n->name); + event_del(&n->mtuevent); + + xasprintf(&envp[0], "NETNAME=%s", netname ? : ""); + xasprintf(&envp[1], "DEVICE=%s", device ? : ""); + xasprintf(&envp[2], "INTERFACE=%s", iface ? : ""); + xasprintf(&envp[3], "NODE=%s", n->name); sockaddr2str(&n->address, &address, &port); - asprintf(&envp[4], "REMOTEADDRESS=%s", address); - asprintf(&envp[5], "REMOTEPORT=%s", port); + xasprintf(&envp[4], "REMOTEADDRESS=%s", address); + xasprintf(&envp[5], "REMOTEPORT=%s", port); envp[6] = NULL; execute_script(n->status.reachable ? "host-up" : "host-down", envp); - asprintf(&name, + xasprintf(&name, n->status.reachable ? "hosts/%s-up" : "hosts/%s-down", n->name); execute_script(name, envp);