summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNanang Izzuddin <nanang@teluu.com>2013-11-07 08:20:30 +0000
committerNanang Izzuddin <nanang@teluu.com>2013-11-07 08:20:30 +0000
commit72f6d11aa23b64d1697d1301c459293b964b175d (patch)
tree587d560f9cb52ae3811d8db27a8c40e4c8c79a55
parentaf9aacf4ba888d6476600c486b6d69a4d269c000 (diff)
Fix #1710: Modified resolver to always remove cache entry from cache hash table first before releasing/resetting cache pool.
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4649 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r--pjlib-util/src/pjlib-util/resolver.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/pjlib-util/src/pjlib-util/resolver.c b/pjlib-util/src/pjlib-util/resolver.c
index 97571612..cdc5d127 100644
--- a/pjlib-util/src/pjlib-util/resolver.c
+++ b/pjlib-util/src/pjlib-util/resolver.c
@@ -1197,9 +1197,12 @@ static void update_res_cache(pj_dns_resolver *resolver,
if (status != PJ_SUCCESS) {
cache = (struct cached_res *) pj_hash_get(resolver->hrescache, key,
sizeof(*key), &hval);
+ /* Remove the entry before releasing its pool (see ticket #1710) */
+ pj_hash_set(NULL, resolver->hrescache, key, sizeof(*key), hval, NULL);
+
+ /* Free the entry */
if (cache && --cache->ref_cnt <= 0)
free_entry(resolver, cache);
- pj_hash_set(NULL, resolver->hrescache, key, sizeof(*key), hval, NULL);
}
@@ -1233,9 +1236,12 @@ static void update_res_cache(pj_dns_resolver *resolver,
if (ttl == 0) {
cache = (struct cached_res *) pj_hash_get(resolver->hrescache, key,
sizeof(*key), &hval);
+ /* Remove the entry before releasing its pool (see ticket #1710) */
+ pj_hash_set(NULL, resolver->hrescache, key, sizeof(*key), hval, NULL);
+
+ /* Free the entry */
if (cache && --cache->ref_cnt <= 0)
free_entry(resolver, cache);
- pj_hash_set(NULL, resolver->hrescache, key, sizeof(*key), hval, NULL);
return;
}
@@ -1252,6 +1258,9 @@ static void update_res_cache(pj_dns_resolver *resolver,
cache->ref_cnt--;
cache = alloc_entry(resolver);
} else {
+ /* Remove the entry before resetting its pool (see ticket #1710) */
+ pj_hash_set(NULL, resolver->hrescache, key, sizeof(*key), hval, NULL);
+
/* Reset cache to avoid bloated cache pool */
reset_entry(&cache);
}