Skip to content
Snippets Groups Projects
  • Mark Michelson's avatar
    5dfefa5e
    Merged revisions 140488 via svnmerge from · 5dfefa5e
    Mark Michelson authored
    https://origsvn.digium.com/svn/asterisk/branches/1.4
    
    ........
    r140488 | mmichelson | 2008-08-29 12:34:17 -0500 (Fri, 29 Aug 2008) | 22 lines
    
    After working on the ao2_containers branch, I noticed
    something a bit strange. In all cases where we provide
    a callback function to ao2_container_alloc, the callback
    function would only return 0 or CMP_MATCH. After inspecting
    the ao2_callback() code carefully, I found that if you're
    only looking for one specific item, then you should return
    CMP_MATCH | CMP_STOP. Otherwise, astobj2 will continue
    traversing the current bucket until the end searching for
    more matches.
    
    In cases like chan_iax2 where in 1.4, all the peers are
    shoved into a single bucket, this makes for potentially
    terrible performance since the entire bucket will be
    traversed even if the peer is one of the first ones come
    across in the bucket.
    
    All the changes I have made were for cases where the 
    callback function defined was passed to ao2_container_alloc
    so that calls to ao2_find could find a unique instance
    of whatever object was being stored in the container.
    
    
    ........
    
    
    git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@140489 65c4cc65-6c06-0410-ace0-fbb531ad65f3
    5dfefa5e
    History
    Merged revisions 140488 via svnmerge from
    Mark Michelson authored
    https://origsvn.digium.com/svn/asterisk/branches/1.4
    
    ........
    r140488 | mmichelson | 2008-08-29 12:34:17 -0500 (Fri, 29 Aug 2008) | 22 lines
    
    After working on the ao2_containers branch, I noticed
    something a bit strange. In all cases where we provide
    a callback function to ao2_container_alloc, the callback
    function would only return 0 or CMP_MATCH. After inspecting
    the ao2_callback() code carefully, I found that if you're
    only looking for one specific item, then you should return
    CMP_MATCH | CMP_STOP. Otherwise, astobj2 will continue
    traversing the current bucket until the end searching for
    more matches.
    
    In cases like chan_iax2 where in 1.4, all the peers are
    shoved into a single bucket, this makes for potentially
    terrible performance since the entire bucket will be
    traversed even if the peer is one of the first ones come
    across in the bucket.
    
    All the changes I have made were for cases where the 
    callback function defined was passed to ao2_container_alloc
    so that calls to ao2_find could find a unique instance
    of whatever object was being stored in the container.
    
    
    ........
    
    
    git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@140489 65c4cc65-6c06-0410-ace0-fbb531ad65f3