You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by re...@apache.org on 2002/11/14 03:04:01 UTC
cvs commit: httpd-2.0/modules/experimental cache_pqueue.c
rederpj 2002/11/13 18:04:01
Modified: . CHANGES
modules/experimental cache_pqueue.c
Log:
This fixes a problem where the underlying cache code
indicated that there was one more element on the cache
than there actually was. This happened since element 0
exists but is not used. This code allocates the correct
number of useable elements and reports the number of
actually used elements. The previous code only allowed
MCacheMaxObjectCount-1 objects to be stored in the
cache. [Paul J. Reder]
Revision Changes Path
1.980 +9 -0 httpd-2.0/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/httpd-2.0/CHANGES,v
retrieving revision 1.979
retrieving revision 1.980
diff -u -r1.979 -r1.980
--- CHANGES 12 Nov 2002 18:29:59 -0000 1.979
+++ CHANGES 14 Nov 2002 02:04:00 -0000 1.980
@@ -1,5 +1,14 @@
Changes with Apache 2.0.44
+ *) This fixes a problem where the underlying cache code
+ indicated that there was one more element on the cache
+ than there actually was. This happened since element 0
+ exists but is not used. This code allocates the correct
+ number of useable elements and reports the number of
+ actually used elements. The previous code only allowed
+ MCacheMaxObjectCount-1 objects to be stored in the
+ cache. [Paul J. Reder]
+
*) mod_setenvif: Add SERVER_ADDR special keyword to allow
envariable setting according to the server IP address
which received the request. [Ken Coar]
1.13 +5 -3 httpd-2.0/modules/experimental/cache_pqueue.c
Index: cache_pqueue.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/experimental/cache_pqueue.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- cache_pqueue.c 14 Aug 2002 01:24:16 -0000 1.12
+++ cache_pqueue.c 14 Nov 2002 02:04:01 -0000 1.13
@@ -98,11 +98,12 @@
return NULL;
}
- if (!(q->d = malloc(sizeof(void*) * n))) {
+ /* Need to allocate n+1 elements since element 0 isn't used. */
+ if (!(q->d = malloc(sizeof(void*) * (n+1)))) {
free(q);
return NULL;
}
- q->avail = q->step = n;
+ q->avail = q->step = (n+1); /* see comment above about n+1 */
q->pri = pri;
q->size = 1;
q->get = get;
@@ -122,7 +123,8 @@
*/
apr_ssize_t cache_pq_size(cache_pqueue_t *q)
{
- return q->size;
+ /* queue element 0 exists but doesn't count since it isn't used. */
+ return (q->size - 1);
}
static void cache_pq_bubble_up(cache_pqueue_t *q, apr_ssize_t i)