Return-Path: Delivered-To: apmail-httpd-cvs-archive@www.apache.org Received: (qmail 43176 invoked from network); 18 Dec 2003 21:22:42 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 18 Dec 2003 21:22:42 -0000 Received: (qmail 54634 invoked by uid 500); 18 Dec 2003 21:22:31 -0000 Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 54463 invoked by uid 500); 18 Dec 2003 21:22:30 -0000 Mailing-List: contact cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cvs@httpd.apache.org Received: (qmail 54450 invoked by uid 500); 18 Dec 2003 21:22:30 -0000 Delivered-To: apmail-httpd-2.0-cvs@apache.org Received: (qmail 54447 invoked from network); 18 Dec 2003 21:22:30 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 18 Dec 2003 21:22:30 -0000 Received: (qmail 43167 invoked by uid 1088); 18 Dec 2003 21:22:41 -0000 Date: 18 Dec 2003 21:22:41 -0000 Message-ID: <20031218212241.43166.qmail@minotaur.apache.org> From: stoddard@apache.org To: httpd-2.0-cvs@apache.org Subject: cvs commit: httpd-2.0/modules/experimental mod_mem_cache.c X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N stoddard 2003/12/18 13:22:41 Modified: . CHANGES modules/experimental mod_mem_cache.c Log: Fix segfault in mod_mem_cache when caching streaming dynamic content. PR: 21285, 21287 Revision Changes Path 1.1348 +3 -0 httpd-2.0/CHANGES Index: CHANGES =================================================================== RCS file: /home/cvs/httpd-2.0/CHANGES,v retrieving revision 1.1347 retrieving revision 1.1348 diff -u -r1.1347 -r1.1348 --- CHANGES 18 Dec 2003 15:29:41 -0000 1.1347 +++ CHANGES 18 Dec 2003 21:22:40 -0000 1.1348 @@ -1,6 +1,9 @@ Changes with Apache 2.1.0-dev [Remove entries to the current 2.0 section below, when backported] + *) Fix segfault in mod_mem_cache cache_insert() due to cache size + becoming negative. PR: 21285, 21287 + [Bill Stoddard, Massimo Torquati, Jean-Jacques Clar] *) Add Polish translation of error messages. PR 25101. [Tomasz Kepczynski ] 1.100 +22 -1 httpd-2.0/modules/experimental/mod_mem_cache.c Index: mod_mem_cache.c =================================================================== RCS file: /home/cvs/httpd-2.0/modules/experimental/mod_mem_cache.c,v retrieving revision 1.99 retrieving revision 1.100 diff -u -r1.99 -r1.100 --- mod_mem_cache.c 10 Dec 2003 03:22:32 -0000 1.99 +++ mod_mem_cache.c 18 Dec 2003 21:22:41 -0000 1.100 @@ -1043,7 +1043,28 @@ if (sconf->lock) { apr_thread_mutex_lock(sconf->lock); } - cache_remove(sconf->cache_cache, obj); + if (obj->cleanup) { + /* If obj->cleanup is set, the object has been prematurly + * ejected from the cache by the garbage collector. Add the + * object back to the cache. If an object with the same key is + * found in the cache, eject it in favor of the completed obj. + */ + cache_object_t *tmp_obj = + (cache_object_t *) cache_find(sconf->cache_cache, obj->key); + if (tmp_obj) { + cache_remove(sconf->cache_cache, tmp_obj); + sconf->object_cnt--; + sconf->cache_size -= mobj->m_len; + tmp_obj->cleanup = 1; + if (!tmp_obj->refcount) { + cleanup_cache_object(tmp_obj); + } + } + obj->cleanup = 0; + } + else { + cache_remove(sconf->cache_cache, obj); + } mobj->m_len = obj->count; cache_insert(sconf->cache_cache, obj); sconf->cache_size -= (mobj->m_len - obj->count);