From e5d12da5a0e7363b103cf9574e881254b415eaca Mon Sep 17 00:00:00 2001 From: Ian Holsman Date: Tue, 12 Feb 2002 22:11:30 +0000 Subject: [PATCH] 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 --- modules/experimental/mod_mem_cache.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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; } -- 2.40.0