Improve performance of edge updates.
authorGuus Sliepen <guus@tinc-vpn.org>
Sat, 27 Feb 2016 13:18:20 +0000 (14:18 +0100)
committerGuus Sliepen <guus@tinc-vpn.org>
Sat, 27 Feb 2016 13:18:20 +0000 (14:18 +0100)
src/protocol_edge.c

index 3dfff05e1845eb4120febad7df96ba1d08255269..e048703fdd62baec5687d3b3e1d019ac0b5c243f 100644 (file)
@@ -125,8 +125,19 @@ bool add_edge_h(connection_t *c) {
                        } else {
                                ifdebug(PROTOCOL) logger(LOG_WARNING, "Got %s from %s (%s) which does not match existing entry",
                                                   "ADD_EDGE", c->name, c->hostname);
-                               edge_del(e);
+                               e->options = options;
+                               if(sockaddrcmp(&e->address, &address)) {
+                                       sockaddrfree(&e->address);
+                                       e->address = address;
+                               }
+                               if(e->weight != weight) {
+                                       avl_node_t *node = avl_unlink(edge_weight_tree, e);
+                                       e->weight = weight;
+                                       avl_insert_node(edge_weight_tree, node);
+                               }
+
                                graph();
+                               return true;
                        }
                } else
                        return true;