summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-07-07 15:17:50 -0400
committerNick Mathewson <nickm@torproject.org>2011-07-07 15:28:45 -0400
commita4d339cf082f27fa5852a383ff9d3a9d2d37e08d (patch)
tree1ae6b986fd8a2784ae40f12a98d2704ce163144d
parentaeb117f62c1831a434e167cdf6b0cc4e970728ce (diff)
downloadtor-a4d339cf082f27fa5852a383ff9d3a9d2d37e08d.tar.gz
tor-a4d339cf082f27fa5852a383ff9d3a9d2d37e08d.zip
Make nodelist_purge avoid orphaned microdescs in rs-less nodes
We have an invariant that a node_t should have an md only if it has a routerstatus. nodelist_purge tried to preserve this by removing all nodes without a routerstatus or a routerinfo. But this left nodes with a routerinfo and a microdesc untouched, even if they had a routerstatus. Bug found by frosty_un.
-rw-r--r--src/or/nodelist.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/or/nodelist.c b/src/or/nodelist.c
index 08131219b7..308aaa8658 100644
--- a/src/or/nodelist.c
+++ b/src/or/nodelist.c
@@ -317,6 +317,12 @@ nodelist_purge(void)
for (iter = HT_START(nodelist_map, &the_nodelist->nodes_by_id); iter; ) {
node_t *node = *iter;
+ if (node->md && !node->rs) {
+ /* An md is only useful if there is an rs. */
+ node->md->held_by_node = 0;
+ node->md = NULL;
+ }
+
if (node_is_usable(node)) {
iter = HT_NEXT(nodelist_map, &the_nodelist->nodes_by_id, iter);
} else {