Commit 03720b39 authored by Roger Dingledine's avatar Roger Dingledine
Browse files

stop wasting time doing a case insensitive comparison for every dns name

every time we do any lookup. canonicalize the names to lowercase and be
done with it.


svn:r4035
parent 46089c49
...@@ -81,7 +81,7 @@ static SPLAY_HEAD(cache_tree, cached_resolve) cache_root; ...@@ -81,7 +81,7 @@ static SPLAY_HEAD(cache_tree, cached_resolve) cache_root;
static int compare_cached_resolves(struct cached_resolve *a, static int compare_cached_resolves(struct cached_resolve *a,
struct cached_resolve *b) { struct cached_resolve *b) {
/* make this smarter one day? */ /* make this smarter one day? */
return strncasecmp(a->address, b->address, MAX_ADDRESSLEN); return strncmp(a->address, b->address, MAX_ADDRESSLEN);
} }
SPLAY_PROTOTYPE(cache_tree, cached_resolve, node, compare_cached_resolves); SPLAY_PROTOTYPE(cache_tree, cached_resolve, node, compare_cached_resolves);
...@@ -246,6 +246,9 @@ int dns_resolve(connection_t *exitconn) { ...@@ -246,6 +246,9 @@ int dns_resolve(connection_t *exitconn) {
* resolves in the tree. */ * resolves in the tree. */
purge_expired_resolves(now); purge_expired_resolves(now);
/* lower-case exitconn->address, so it's in canonical form */
tor_strlower(exitconn->address);
/* now check the tree to see if 'address' is already there. */ /* now check the tree to see if 'address' is already there. */
strlcpy(search.address, exitconn->address, sizeof(search.address)); strlcpy(search.address, exitconn->address, sizeof(search.address));
resolve = SPLAY_FIND(cache_tree, &cache_root, &search); resolve = SPLAY_FIND(cache_tree, &cache_root, &search);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment