Changeset 4553


Ignore:
Timestamp:
Jul 8, 2013 1:44:48 AM (7 years ago)
Author:
nanang
Message:

Re #1686: avoid cache entry destroy in update_res_cache() when it is being used by callback.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib-util/src/pjlib-util/resolver.c

    r4552 r4553  
    11981198        cache = (struct cached_res *) pj_hash_get(resolver->hrescache, key,  
    11991199                                                  sizeof(*key), &hval); 
    1200         if (cache) 
     1200        if (cache && --cache->ref_cnt <= 0) 
    12011201            free_entry(resolver, cache); 
    12021202        pj_hash_set(NULL, resolver->hrescache, key, sizeof(*key), hval, NULL); 
     
    12341234        cache = (struct cached_res *) pj_hash_get(resolver->hrescache, key,  
    12351235                                                  sizeof(*key), &hval); 
    1236         if (cache) 
     1236        if (cache && --cache->ref_cnt <= 0) 
    12371237            free_entry(resolver, cache); 
    12381238        pj_hash_set(NULL, resolver->hrescache, key, sizeof(*key), hval, NULL); 
     
    12441244                                              sizeof(*key), &hval); 
    12451245    if (cache == NULL) { 
     1246        cache = alloc_entry(resolver); 
     1247    } else if (cache->ref_cnt > 1) { 
     1248        /* When cache entry is being used by callback (to app), just decrement 
     1249         * ref_cnt so it will be freed after the callback returns and allocate 
     1250         * new entry. 
     1251         */ 
     1252        cache->ref_cnt--; 
    12461253        cache = alloc_entry(resolver); 
    12471254    } else { 
Note: See TracChangeset for help on using the changeset viewer.