From 8dcd2a9995ce05e36221212a95767d33a1d14c50 Mon Sep 17 00:00:00 2001 From: thorkill Date: Mon, 6 Jul 2015 01:52:40 +0200 Subject: [PATCH] Do not delete edges which differ only by weight Added special case where we get weight update from other node. Previous version called edge_del() which caused segmentation faults in mst_kruskal. --- src/protocol_edge.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/protocol_edge.c b/src/protocol_edge.c index 555b654b..61e96af3 100644 --- a/src/protocol_edge.c +++ b/src/protocol_edge.c @@ -135,7 +135,7 @@ bool add_edge_h(connection_t *c, const char *request) { e = lookup_edge(from, to); if(e) { - if(e->weight != weight || e->options != options || sockaddrcmp(&e->address, &address)) { + if(e->options != options || sockaddrcmp(&e->address, &address)) { if(from == myself) { logger(DEBUG_PROTOCOL, LOG_WARNING, "Got %s from %s (%s) for ourself which does not match existing entry", "ADD_EDGE", c->name, c->hostname); @@ -172,7 +172,14 @@ bool add_edge_h(connection_t *c, const char *request) { return true; } + } else if(e->weight != weight){ + logger(DEBUG_PROTOCOL, LOG_WARNING, "Got %s from %s (%s) with new weight %d -> %d", + "ADD_EDGE", c->name, c->hostname, e->weight, weight); + edge_update_weigth(e, weight); + graph(); + return true; } else { + sockaddrfree(&local_address); return true; }