[asterisk-dev] ASTERISK-14769 r342112 OBJ_KEY

Richard Mudgett rmudgett at digium.com
Wed Oct 26 10:29:28 CDT 2011


> Hi there there should be OBJ_POINTER support in the CMP callback not
> sure about OBJ_KEY that seems to only be used for the HASH callback.
> 
> ive been poking app_queue [RB1538] and have moved all ao2_find(queues
> to
> use the OBJ_KEY method and OBJ_POINTER for 10.
> 

The OBJ_KEY flag is currently only in trunk.

When a container is created, you can supply two callbacks.  A hash
function and a compare function.  If the container is going to
support the OBJ_KEY flag, both functions must handle the OBJ_KEY
flag.  Otherwise, those callbacks will misinterpret the passed in
pointer by assuming it is an object (OBJ_POINTER).  These two callback
functions must assume OBJ_POINTER unless they see OBJ_KEY for best
results.

The hash function is called whenever the OBJ_POINTER or OBJ_KEY flag
is set during an ao2_callback/ao2_find.  The ao2_link and ao2_unlink
functions internally also call the hash function.

The saved container compare function is called when ao2_find is used.
Remember that ao2_find is just a convenience function for ao2_callback
with an assumed callback function.

Richard



More information about the asterisk-dev mailing list