r2232 - trunk/varnish-cache/bin/varnishd

Dag-Erling Smørgrav des at linpro.no
Fri Nov 9 11:45:18 CET 2007

Dag-Erling Smørgrav <des at linpro.no> writes:
> "Poul-Henning Kamp" <phk at phk.freebsd.dk> writes:
> > If we get two events for the fd in the same batch, this fix will
> > not save us.  I'm not sure if FreeBSD's current kqueue implementation
> > prevents that from happening.
> I think that in such a case, we would get a single kevent with
> (kp->data > 0) and (kp->flags & EV_EOF).  I'll have to check the code
> to be sure.

I checked the code, this is indeed the case.

The bad news is that we just caught an assert in SES_Delete() again,
so there must be another bug in here somewhere.

More thinking:

 - VTAILQ_REMOVE() is not idempotent, removing an element from the
   list twice (as will happen when this race occurs) will corrupt the

 - The tail queue should probably be a binary heap instead.

 - kevent changes can be buffered safely if we flush the buffer at the
   end of the loop in vca_kqueue_main().  Since we process (at most)
   NKEV kevents at a time, we will never have more than NKEV kevent
   changes to apply at that point, so it's safe to use a static

Dag-Erling Smørgrav
Senior Software Developer
Linpro AS - www.linpro.no

More information about the varnish-commit mailing list