]> granicus.if.org Git - apache/commitdiff
fix a race condition.
authorIan Holsman <ianh@apache.org>
Tue, 12 Feb 2002 22:11:30 +0000 (22:11 +0000)
committerIan Holsman <ianh@apache.org>
Tue, 12 Feb 2002 22:11:30 +0000 (22:11 +0000)
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

index 8e1655b79c96170aea29a09def4514ad94f73cdc..f3401754ba2355001de7155c78affb621ff86264 100644 (file)
@@ -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;
 }