aboutsummaryrefslogtreecommitdiff
path: root/src/or/nodelist.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-07-07 11:14:04 -0400
committerNick Mathewson <nickm@torproject.org>2011-07-07 11:14:04 -0400
commit174cbff8cf855dc1bbf690694f539ba3f85a508c (patch)
tree34fbd173ca70e2c2dc946c20234481f91ff483be /src/or/nodelist.c
parent6b670d6032b33f255f88e31a727b8f042b1dfcef (diff)
parent4ba9f3e31702020eaa336ccb33294568cda256eb (diff)
downloadtor-174cbff8cf855dc1bbf690694f539ba3f85a508c.tar.gz
tor-174cbff8cf855dc1bbf690694f539ba3f85a508c.zip
Merge remote-tracking branch 'public/bug3153'
Conflicts: src/or/nodelist.c
Diffstat (limited to 'src/or/nodelist.c')
-rw-r--r--src/or/nodelist.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/or/nodelist.c b/src/or/nodelist.c
index 96b65a1321..08131219b7 100644
--- a/src/or/nodelist.c
+++ b/src/or/nodelist.c
@@ -158,8 +158,12 @@ nodelist_add_microdesc(microdesc_t *md)
if (rs == NULL)
return NULL;
node = node_get_mutable_by_id(rs->identity_digest);
- if (node)
+ if (node) {
+ if (node->md)
+ node->md->held_by_node = 0;
node->md = md;
+ md->held_by_node = 1;
+ }
return node;
}
@@ -184,8 +188,12 @@ nodelist_set_consensus(networkstatus_t *ns)
if (ns->flavor == FLAV_MICRODESC) {
if (node->md == NULL ||
tor_memneq(node->md->digest,rs->descriptor_digest,DIGEST256_LEN)) {
+ if (node->md)
+ node->md->held_by_node = 0;
node->md = microdesc_cache_lookup_by_digest256(NULL,
rs->descriptor_digest);
+ if (node->md)
+ node->md->held_by_node = 1;
}
}
@@ -240,8 +248,10 @@ void
nodelist_remove_microdesc(const char *identity_digest, microdesc_t *md)
{
node_t *node = node_get_mutable_by_id(identity_digest);
- if (node && node->md == md)
+ if (node && node->md == md) {
node->md = NULL;
+ md->held_by_node = 0;
+ }
}
/** Tell the nodelist that <b>ri</b> is no longer in the routerlist. */
@@ -288,6 +298,8 @@ node_free(node_t *node)
{
if (!node)
return;
+ if (node->md)
+ node->md->held_by_node = 0;
tor_assert(node->nodelist_idx == -1);
tor_free(node);
}
@@ -375,6 +387,8 @@ nodelist_assert_ok(void)
microdesc_t *md =
microdesc_cache_lookup_by_digest256(NULL, rs->descriptor_digest);
tor_assert(md == node->md);
+ if (md)
+ tor_assert(md->held_by_node == 1);
}
} SMARTLIST_FOREACH_END(rs);
}