W3C home > Mailing lists > Public > www-lib@w3.org > July to September 2000

problem in HTCache.c

From: Jens Meggers <jens@meggers.com>
Date: Tue, 8 Aug 2000 11:26:09 +0200
Message-ID: <004701c0011a$afb3af60$1002a8c0@pille>
To: <www-lib@w3.org>
Hi lib-WWW users,

I found a problem in HTCacheGarbage() of HTCache.c.
The procedure walks through the cache entires. When an entry is expired, it deletes the object with HTCache_remove(pres) and sets the cur pointer to the former valid pointer by calling cur = old_cur;
However, if HTCache_remove(pres) does not succeed, we are going into an endless loop. In my implementation this happens because a cache entry was locked. I assume that locked entires cannot be deleted, so I changed the code to the following:

if (pres->freshness_lifetime < current_age) {
   if (HTCache_remove(pres)) {;
        cur = old_cur;
    } else {
        old_cur = cur;
    }
} else {
    old_cur = cur;
}

in the first for-loop. In the second for-loop, where the entires are cleared according to their hit rates, I also changed the code:

if (pres->size > HTCacheMaxEntrySize || pres->hits <= hits) {
    if (HTCache_remove(pres)) {;
        cur = old_cur;
        removed = YES;
    } else {
        old_cur = cur;
    }
} else {
    old_cur = cur;
}

The only thing I added is the if statement around HTChache_remove() that is missing in the original version.

What do you think?


Best regards,

Jens
Received on Tuesday, 8 August 2000 05:27:10 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 23 April 2007 18:18:37 GMT