Send monitor announcement based on reachability change instead of routing calcs

This commit is contained in:
Jeremy Lakeman 2012-12-11 14:21:38 +10:30
parent ed8be33f82
commit 542a9f817d
2 changed files with 6 additions and 2 deletions

View File

@ -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;
}

View File

@ -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;