cbdata, final review

From: Henrik Nordstrom <hno@dont-contact.us>
Date: Thu, 11 Oct 2001 01:41:06 +0200

Hello.

cbdata is now in it's final stages, and I call for a final review of the
new cbdata API I am considering for Squid-2.6.

http://devel.squid-cache.org/cbdata/Programming-Guide/prog-guide-20.html

Note: cbdata is intended for callback data and is tailored specifically
to make callbacks less dangerous leaving as few windows of errors as
possible. It is not suitable or intended as a generic referencecounted
memory allocator.

I am not 100% satisfied with the
cbdataReferenceValid/cbdataReferenceDone and the
cbdataReferenceDoneValid constructs, but I haven't found a fully
satisfactory language construct which covers all cases. I prefer the
cbdataReferenceDoneValid approach, but at some locations it may make
things more complex than needed and does not allow for NULL cbdata
pointers.

cbdataReferenceValid/cbdataReferenceDone has the problem of keeping the
entry locked while the callback is being made, plus that there is a
potential race window in the function making the callback if another
callback could be installed while the first is being called.

cbdataReferenceDone has the issue of requiring a temporary local
variable and leaves a stale reference in this variable after the
callback has returned.

Also, the two approaches differs in the meaning of NULL pointers.
cbdataReferenceValid considers NULL pointers valid which is somewhat
inconsistent with cbdataReferenceDone clearing the pointer to NULL, but
at the same time allows for dataless callbacks that cannot be cancelled.
cbdataReferenceDoneValid does not allow NULL pointers and will consider
them invalid.

Regards
Henrik
Received on Wed Oct 10 2001 - 17:40:34 MDT

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