when removing dead helpers, only write or_state to disk once at the

end, not for every helper you remove.


svn:r5568
This commit is contained in:
Roger Dingledine 2005-12-11 11:56:17 +00:00
parent 5981169440
commit a131783c8b

View File

@ -1746,6 +1746,7 @@ remove_dead_helpers(void)
char tbuf[ISO_TIME_LEN+1]; char tbuf[ISO_TIME_LEN+1];
time_t now = time(NULL); time_t now = time(NULL);
int i; int i;
int changed = 0;
for (i = 0; i < smartlist_len(helper_nodes); ) { for (i = 0; i < smartlist_len(helper_nodes); ) {
helper_node_t *helper = smartlist_get(helper_nodes, i); helper_node_t *helper = smartlist_get(helper_nodes, i);
@ -1767,10 +1768,11 @@ remove_dead_helpers(void)
helper->nickname, dbuf, why, tbuf); helper->nickname, dbuf, why, tbuf);
tor_free(helper); tor_free(helper);
smartlist_del(helper_nodes, i); smartlist_del(helper_nodes, i);
helper_nodes_changed();
} else } else
++i; ++i;
} }
if (changed)
helper_nodes_changed();
} }
/** A new directory or router-status has arrived; update the down/listed status /** A new directory or router-status has arrived; update the down/listed status
@ -1860,8 +1862,8 @@ helper_node_set_status(const char *digest, int succeeded)
if (!memcmp(helper->identity, digest, DIGEST_LEN)) { if (!memcmp(helper->identity, digest, DIGEST_LEN)) {
if (succeeded) { if (succeeded) {
if (helper->down_since) { if (helper->down_since) {
/*XXXX shouldn't warn. NM */ /*XXXX shouldn't be so loud. NM */
warn(LD_CIRC, notice(LD_CIRC,
"Connection to formerly down helper node '%s' succeeded. " "Connection to formerly down helper node '%s' succeeded. "
"%d/%d helpers usable.", helper->nickname, "%d/%d helpers usable.", helper->nickname,
num_live_helpers(), smartlist_len(helper_nodes)); num_live_helpers(), smartlist_len(helper_nodes));