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]
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@97510
13f79535-47bb-0310-9956-
ffa450edef68
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]
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;
*/
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)