diff options
author | Nick Mathewson <nickm@torproject.org> | 2011-09-28 13:29:01 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2011-09-28 13:40:21 -0400 |
commit | a4b7525c3ce596d4221575806d44652aaa9047a9 (patch) | |
tree | a5d2a00ace1788a3167cd6adc86c94f5ef77930f /src/or/nodelist.c | |
parent | e98c9a1bf6e64a641fd904cbef58b1e46da89e91 (diff) | |
download | tor-a4b7525c3ce596d4221575806d44652aaa9047a9.tar.gz tor-a4b7525c3ce596d4221575806d44652aaa9047a9.zip |
Fix a crash bug in tor_assert(md->held_by_node)
The fix is to turn held_by_node into a reference count.
Fixes bug 4118; bugfix on 0.2.3.1-alpha.
Diffstat (limited to 'src/or/nodelist.c')
-rw-r--r-- | src/or/nodelist.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/or/nodelist.c b/src/or/nodelist.c index 308aaa8658..39bc082450 100644 --- a/src/or/nodelist.c +++ b/src/or/nodelist.c @@ -160,9 +160,9 @@ nodelist_add_microdesc(microdesc_t *md) node = node_get_mutable_by_id(rs->identity_digest); if (node) { if (node->md) - node->md->held_by_node = 0; + node->md->held_by_nodes--; node->md = md; - md->held_by_node = 1; + md->held_by_nodes++; } return node; } @@ -189,11 +189,11 @@ nodelist_set_consensus(networkstatus_t *ns) 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->held_by_nodes--; node->md = microdesc_cache_lookup_by_digest256(NULL, rs->descriptor_digest); if (node->md) - node->md->held_by_node = 1; + node->md->held_by_nodes++; } } @@ -250,7 +250,7 @@ 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) { node->md = NULL; - md->held_by_node = 0; + md->held_by_nodes--; } } @@ -299,7 +299,7 @@ node_free(node_t *node) if (!node) return; if (node->md) - node->md->held_by_node = 0; + node->md->held_by_nodes--; tor_assert(node->nodelist_idx == -1); tor_free(node); } @@ -319,7 +319,7 @@ nodelist_purge(void) if (node->md && !node->rs) { /* An md is only useful if there is an rs. */ - node->md->held_by_node = 0; + node->md->held_by_nodes--; node->md = NULL; } @@ -394,7 +394,7 @@ nodelist_assert_ok(void) microdesc_cache_lookup_by_digest256(NULL, rs->descriptor_digest); tor_assert(md == node->md); if (md) - tor_assert(md->held_by_node == 1); + tor_assert(md->held_by_nodes >= 1); } } SMARTLIST_FOREACH_END(rs); } |