Re: Race condition in storeClose()

From: Adrian Chadd <adrian@dont-contact.us>
Date: Tue, 28 Nov 2000 06:34:12 +0800

On Mon, Nov 27, 2000, Andres Kroonmaa wrote:
> On 25 Nov 2000, at 2:17, Andres Kroonmaa <andre@online.ee> wrote:
>
> > @@ -143,6 +143,8 @@
> > if (storeAufsSomethingPending(sio)) {
> > + if (aiostate->flags.reading)
> > + aioCancel(aiostate->fd);
>
> I'm still having crashes with aioCancel applied. Seems that problem is
> not only in that storeClose doesn't cancel aioRead, but also in the fact
> that storeClose isn't called timely at all.
>
> To me it seems that there are zillions of places in client_side.c
> where client socket buffer is released without making sure that pending
> aioread is canceled. Basically every place where we release client buff,
> we should first cancel pending read with storeunregister, or have
> clientbuffer cblocked, so that its final free is done during aiocallback
> checks.
> This part of squid is so complex that I'm very unsure about where and
> what should we do with that.

ok. my commloops code tidied this up a little. If you passed
storeClientCopy a NULL buffer, it'd return a pointer for you to
get data from. The idea here is that it'll either allocate you
a buffer for swapping in objects, or it'll be in the stmem chain
attached to a memObject (ie in memory) ..

If you want to look at it the bulk of the changes are in
client_side.c and store_client.c .. there are other bits attached
to it (ignore the server copying stuff, ok? :) but the code shouldn't
suffer from the strangeness that exists there now.

It saves on a memory copy and a stmem list walk in most cases as
I've unravelled some of the magic in stmem.c and stuck it in
client_side.c to keep state of the last stmem buf we looked at.
from my initial poking this saved a lot of time since most
accesses were very linear (ie from start to finish..)

And yes, the real way to deal with this is to kill it with extreme
prejudice, but I just don't have the time on my hands to do this
right now. :-)

Adrian

-- 
Adrian Chadd			"God: Damn! I left pot everywhere!
<adrian@creative.net.au>	  Now I'll have to create Republicans!"
				    - Bill Hicks
Received on Mon Nov 27 2000 - 15:34:21 MST

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:13:00 MST