From 80ccfb289487c381c3dfe18f827d66f87a09c0fa Mon Sep 17 00:00:00 2001 From: thorkill Date: Tue, 7 Jul 2015 20:50:53 +0200 Subject: [PATCH] Update weight if needed at the beginning --- src/protocol_edge.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/protocol_edge.c b/src/protocol_edge.c index b27903e5..00511dfa 100644 --- a/src/protocol_edge.c +++ b/src/protocol_edge.c @@ -135,6 +135,16 @@ bool add_edge_h(connection_t *c, const char *request) { e = lookup_edge(from, to); if(e) { + /* Update weight first */ + 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); + if (e->reverse) + edge_update_weigth(e->reverse, weight); + graph(); + } + 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", @@ -172,15 +182,6 @@ 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); - if (e->reverse) - edge_update_weigth(e->reverse, weight); - - graph(); - return true; } else { sockaddrfree(&local_address);