diff options
author | Nick Mathewson <nickm@torproject.org> | 2013-07-16 13:59:31 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2013-08-15 12:03:35 -0400 |
commit | 34d02484c06f26653563176e4b5db2829ae4bc23 (patch) | |
tree | c2f259e9c023d4d98b16628845d314390635f29f /src/or/geoip.c | |
parent | 50136b66981ae80c2b139aa441a8472c84bc11e6 (diff) | |
download | tor-34d02484c06f26653563176e4b5db2829ae4bc23.tar.gz tor-34d02484c06f26653563176e4b5db2829ae4bc23.zip |
Fix hash functions for transport_name in client entry
Diffstat (limited to 'src/or/geoip.c')
-rw-r--r-- | src/or/geoip.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/or/geoip.c b/src/or/geoip.c index b4f54d4eb2..21dceed3da 100644 --- a/src/or/geoip.c +++ b/src/or/geoip.c @@ -486,23 +486,16 @@ static HT_HEAD(clientmap, clientmap_entry_t) client_history = static INLINE unsigned clientmap_entry_hash(const clientmap_entry_t *a) { - return ht_improve_hash(tor_addr_hash(&a->addr)); + unsigned h = tor_addr_hash(&a->addr); + if (a->transport_name) + h += ht_string_hash(a->transport_name); + return ht_improve_hash(h); } /** Hashtable helper: compare two clientmap_entry_t values for equality. */ static INLINE int clientmap_entries_eq(const clientmap_entry_t *a, const clientmap_entry_t *b) { - /* If one entry contains a transport and the other doesn't, then - they are not equal. */ - if (a->transport_name && !b->transport_name) - return 0; - if (!a->transport_name && b->transport_name) - return 0; - /* If entries contain different transports, they they are not - equal. */ - if (a->transport_name && - b->transport_name && - strcmp(a->transport_name, b->transport_name)) + if (strcmp_opt(a->transport_name, b->transport_name)) return 0; return !tor_addr_compare(&a->addr, &b->addr, CMP_EXACT) && |