EventDialer cbdataReference abuse

From: Henrik Nordström <henrik@dont-contact.us>
Date: Sat, 23 Feb 2008 13:34:48 +0100

http://www.squid-cache.org/Versions/v3/HEAD/changesets/11438.patch

This is plain wrong use of cbdataReference(). cbdataReference returns a
reference to the cbdata object, and you are meant to use
cbdataReferenceDone on that reference when done.

The current implementation happens to return the same pointer due to
historical reasons, but this should not be counted on.

If you need to manually lock/unlock cbdata objects for whatever stange
reason then use the cbdataInternalLock/Unlock calls.

The idea with cbdata is that when you are given a cbdata enabled object
use cbdataReference on it to get a reference safe to be saved between
call events. Then use cbdataReferenceValid to verify it's validity if
needed, cbdataReferenceDone() to get rid of the reference (also kills
the pointer to avoid "reuse after free), or cbdataReferenceValidDone()
to do both in one step suitable for calling a callback with the cbdata
variable as argument, or other similar chain of events.

I haven't yet analyzed this code to tell if it should use cbdataInternal
as a workaround for a race condition or if it's a design error in how
EventDialer uses cbdata. Saw it while working wiht Amos to sort out what
changesets should be merged back to 3.0..

Regards
Henrik

Received on Sat Feb 23 2008 - 05:38:52 MST

This archive was generated by hypermail pre-2.1.9 : Sat Mar 01 2008 - 12:00:09 MST