problem in HTCache.c

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 UTC