diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-04-11 15:50:06 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-04-15 11:21:32 -0400 |
commit | 06ecb9432f4596f10e73f82bb1ff6677060756f9 (patch) | |
tree | ac9f568f9fc3d9082dfee524c68baf14a4be2cb3 /src/or/conscache.c | |
parent | b081a7ed21ae729f6e195715e130edaca3e0b7fe (diff) | |
download | tor-06ecb9432f4596f10e73f82bb1ff6677060756f9.tar.gz tor-06ecb9432f4596f10e73f82bb1ff6677060756f9.zip |
conscache.c: do not match entries that are slated for removal.
Diffstat (limited to 'src/or/conscache.c')
-rw-r--r-- | src/or/conscache.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/or/conscache.c b/src/or/conscache.c index 2a6e1445e3..a186163b6c 100644 --- a/src/or/conscache.c +++ b/src/or/conscache.c @@ -174,6 +174,8 @@ consensus_cache_find_first(consensus_cache_t *cache, * Given a <b>cache</b>, add every entry to <b>out<b> for which * <b>key</b>=<b>value</b>. If <b>key</b> is NULL, add every entry. * + * Do not add any entry that has been marked for removal. + * * Does not adjust reference counts. */ void @@ -182,12 +184,15 @@ consensus_cache_find_all(smartlist_t *out, const char *key, const char *value) { - if (! key) { - smartlist_add_all(out, cache->entries); - return; - } - SMARTLIST_FOREACH_BEGIN(cache->entries, consensus_cache_entry_t *, ent) { + if (ent->can_remove == 1) { + /* We want to delete this; pretend it isn't there. */ + continue; + } + if (! key) { + smartlist_add(out, ent); + continue; + } const char *found_val = consensus_cache_entry_get_value(ent, key); if (found_val && !strcmp(value, found_val)) { smartlist_add(out, ent); |