On 4/14/06, Zoran Vasiljevic <[EMAIL PROTECTED]> wrote:
>
> On 14.04.2006, at 11:58, Zoran Vasiljevic wrote:
>
> > OK. This is the beast:
> >
> > test cache-6.2 {eval ttl} -body {
> > ns_cache_eval -ttl 1 -- c1 k1 {return a}
> > after 1500
> > ns_cache_eval c1 k1 {return b}
> > } -cleanup {
> > ns_cache_flush c1
> > } -result b
>
> It is now fixed in the CVS. Stephen please read
> the comment I put in the code. I do not know if
> this is really correct as it ignores the expired
> entry and just reuses it. OTOH, if I do it "right"
> i.e. purge then re-create, the test routine starts
> to throw errors. So it is either the test that is
> wrong or the API that is wrong. As it is in CVS now
> it works with the current test routine and does not
> crash. Admitently, expired entries are not expired
> at that place, rather re-used.
There were a couple of errors: a call to Ns_CacheFreeEntry() crept
into ExpireEntry() when Ns_UnsetValue() was enough. Looks like a
thinko, mirroring the code of PruneEntry() below it. Also, cache
flushes were causing Ns_CacheWaitCreateEntry() to fail, which isn't
what callers expect. The entry is just recreated in that case. I
split the code between the two similar functions and it seems a lot
clearer what's going on now.