Re: cbdataFree

From: Robert Collins <robert.collins@dont-contact.us>
Date: Mon, 7 May 2001 22:45:14 +1000

refcounted io buffers for the filter code.

refcount differs from cbdata in that it's being passed along a chain of
users that _may split_. And if the chain splits, then two cbdataFree's
would occur.

ie:

1) a source (say http server side code) creates a buffer bar. (locks=1)
2) bar then gets passed to the broker. the broker doesn't lock the
buffer - it doesn't care about it. However the broker passes the buffer
to _both_ the object store for storage and the client side code for
passing to the client.
3) both the store and the client lock the buffer until they've
respectively commited and sent it. (locks=3)
4) the source unlocks the buffer once the call chain returns. (locks=2)
5) the store completes (locks=1)
6) the client side write completes (locks=0, buffer is freed).

I'm happy to use straight cbdata, with an overlaid unLock and Lock
function and put in a _new_ refcount variable - but that seems rather..
uhmm wasteful. I'd far rather reuse the cbdata locks variable.

Rob

----- Original Message -----
From: "Adrian Chadd" <adrian@creative.net.au>
To: "Robert Collins" <robert.collins@itdomain.com.au>
Cc: <squid-dev@squid-cache.org>
Sent: Monday, May 07, 2001 10:31 PM
Subject: Re: cbdataFree

> On Mon, May 07, 2001, Robert Collins wrote:
> > This macro:
> >
> > #define cbdataFree(var) (var = (var != NULL ?
cbdataInternalFree(var):
> > NULL))
> >
> > is a problem for me:
> > I'm build a refcounted structure.
> > the cbdata code has provision to allow the following sequence:
> >
> > CBDATA_INIT_TYPE_FREECB(footype, freefoo)
> >
> > foo=cbdataAlloc(footype);
> > cbdataLock(foo);
> > cbdataFree(foo);
>
> At this point in time you can't use foo anymore.
> It is marked "invalid".
>
> > access, lock and unlock foo until a matching
> > cbdataUnlock(foo);
> > occurs and then freefoo(foo) is automatically called.
> >
> > However the above macro is setting foo to NULL !? (because
> > cbdataInternalFree is returning NULL).
> >
> > Is this by design or oversite?
>
> Design. :-)
>
>
> What exactly are you trying to do?
>
>
>
> Adrian
>
>
> --
> Adrian Chadd "How could we possibly use sex to get
> <adrian@creative.net.au> what we want?
> Sex _IS_ what we want!" -- Fraser
>
Received on Mon May 07 2001 - 06:47:32 MDT

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