From: Ian Holsman Date: Tue, 12 Feb 2002 22:11:30 +0000 (+0000) Subject: fix a race condition. X-Git-Tag: 2.0.33~291 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e5d12da5a0e7363b103cf9574e881254b415eaca;p=apache fix a race condition. 2 threads both trying to remove the same URL at the same time. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@93378 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/experimental/mod_mem_cache.c b/modules/experimental/mod_mem_cache.c index 8e1655b79c..f3401754ba 100644 --- a/modules/experimental/mod_mem_cache.c +++ b/modules/experimental/mod_mem_cache.c @@ -351,12 +351,18 @@ static int remove_entity(cache_handle_t *h) if (sconf->lock) { apr_thread_mutex_lock(sconf->lock); } - apr_hash_set(sconf->cacheht, obj->key, strlen(obj->key), NULL); + /* + * RACE .. some one might have just deleted this object .. so test + * if it is still around + */ + if (obj) { + apr_hash_set(sconf->cacheht, obj->key, strlen(obj->key), NULL); + cleanup_cache_object(obj); + h->cache_obj = NULL; + } if (sconf->lock) { apr_thread_mutex_unlock(sconf->lock); - } - - cleanup_cache_object(obj); + } return OK; }