From 542a9f817d8ca1b3ddec740f2b56ae7a8240adb8 Mon Sep 17 00:00:00 2001 From: Jeremy Lakeman Date: Tue, 11 Dec 2012 14:21:38 +1030 Subject: [PATCH] Send monitor announcement based on reachability change instead of routing calcs --- overlay_address.c | 6 ++++++ overlay_route.c | 2 -- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/overlay_address.c b/overlay_address.c index eabaf654..a1c0ee13 100644 --- a/overlay_address.c +++ b/overlay_address.c @@ -194,6 +194,7 @@ int subscriber_is_reachable(struct subscriber *subscriber){ int set_reachable(struct subscriber *subscriber, int reachable){ if (subscriber->reachable==reachable) return 0; + int old_value = subscriber->reachable; subscriber->reachable=reachable; // These log messages are for use in tests. Changing them may break test scripts. @@ -232,6 +233,11 @@ int set_reachable(struct subscriber *subscriber, int reachable){ if (subscriber==directory_service) directory_registration(); + if ((old_value & REACHABLE) && (!(reachable & REACHABLE))) + monitor_announce_unreachable_peer(subscriber->sid); + if ((!(old_value & REACHABLE)) && (reachable & REACHABLE)) + monitor_announce_peer(subscriber->sid); + return 0; } diff --git a/overlay_route.c b/overlay_route.c index 3f14dd35..adb265af 100644 --- a/overlay_route.c +++ b/overlay_route.c @@ -527,12 +527,10 @@ int overlay_route_recalc_node_metrics(overlay_node *n, time_ms_t now) if (old_best && !best_score){ INFOF("PEER UNREACHABLE, sid=%s", alloca_tohex_sid(n->subscriber->sid)); - monitor_announce_unreachable_peer(n->subscriber->sid); }else if(best_score && !old_best){ INFOF("PEER REACHABLE, sid=%s", alloca_tohex_sid(n->subscriber->sid)); /* Make sure node is advertised soon */ overlay_route_please_advertise(n); - monitor_announce_peer(n->subscriber->sid); } return 0;