Update weight if needed at the beginning
This commit is contained in:
parent
78d0342a12
commit
80ccfb2894
1 changed files with 10 additions and 9 deletions
|
@ -135,6 +135,16 @@ bool add_edge_h(connection_t *c, const char *request) {
|
||||||
e = lookup_edge(from, to);
|
e = lookup_edge(from, to);
|
||||||
|
|
||||||
if(e) {
|
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(e->options != options || sockaddrcmp(&e->address, &address)) {
|
||||||
if(from == myself) {
|
if(from == myself) {
|
||||||
logger(DEBUG_PROTOCOL, LOG_WARNING, "Got %s from %s (%s) for ourself which does not match existing entry",
|
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;
|
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 {
|
} else {
|
||||||
|
|
||||||
sockaddrfree(&local_address);
|
sockaddrfree(&local_address);
|
||||||
|
|
Loading…
Reference in a new issue