Add fails after delete

Anatoly Vorobey
Fri, 16 Jul 2004 02:45:26 +0300

On Thu, Jul 15, 2004 at 12:48:21PM -0700, Brad Fitzpatrick wrote:
> Because exptime == 0, it's not unlinked from the LRU.
> Avva:  I remember why we don't unlink it from the LRU in the time-delayed
> delete case (the old default), but when the provided delay value is 0, why
> don't we just immediately unlink it?

It does seem to be a bug. I think it's crept in after I added realtime() 
to allow relative expiration times, and used it in a delete handler. 
What happened before that was that the item was added to the delete 
queue with expiration time == now() rather than 0.

We could fix it by changing the expiration time to now() if it's 0, 
as a special case in the delete handler, and then also changing < to
<= in this clause:

        if (old_it && old_it->exptime && old_it->exptime < now) {
            old_it = 0;

But actually, I can't see anything wrong with just unlinking it directly 
in the delete handler and not processing it through the queue, when 
exptime is 0. If anyone's printing this item out at the same time or 
otherwise using it, its refcount will prevent it from being deleted 

(thanks, Michael!)

"There's nothing simply good, nor ill alone" -- John Donne