diff options
author | mmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-08-29 17:48:07 +0000 |
---|---|---|
committer | mmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-08-29 17:48:07 +0000 |
commit | 3b47ea0232de5be7caced4d5d90765a01ffb1a79 (patch) | |
tree | 20b402418b2a00cbabb8c6dc02af9d26021dc5ea /channels | |
parent | 12fd7ceadbebb44bc9347f9fb7c392335fa5b512 (diff) |
Merged revisions 140489 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r140489 | mmichelson | 2008-08-29 12:47:17 -0500 (Fri, 29 Aug 2008) | 30 lines
Merged revisions 140488 via svnmerge from
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: http://svn.digium.com/svn/asterisk/branches/1.6.1@140490 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r-- | channels/chan_console.c | 2 | ||||
-rw-r--r-- | channels/chan_iax2.c | 6 | ||||
-rw-r--r-- | channels/chan_sip.c | 8 |
3 files changed, 8 insertions, 8 deletions
diff --git a/channels/chan_console.c b/channels/chan_console.c index c9a59cab3..92777f5ea 100644 --- a/channels/chan_console.c +++ b/channels/chan_console.c @@ -1432,7 +1432,7 @@ static int pvt_cmp_cb(void *obj, void *arg, int flags) { struct console_pvt *pvt = obj, *pvt2 = arg; - return !strcasecmp(pvt->name, pvt2->name) ? CMP_MATCH : 0; + return !strcasecmp(pvt->name, pvt2->name) ? CMP_MATCH | CMP_STOP : 0; } static void stop_streams(void) diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index eb7383db3..d2727f422 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -1312,7 +1312,7 @@ static int peer_cmp_cb(void *obj, void *arg, int flags) { struct iax2_peer *peer = obj, *peer2 = arg; - return !strcmp(peer->name, peer2->name) ? CMP_MATCH : 0; + return !strcmp(peer->name, peer2->name) ? CMP_MATCH | CMP_STOP : 0; } /*! @@ -1332,7 +1332,7 @@ static int user_cmp_cb(void *obj, void *arg, int flags) { struct iax2_user *user = obj, *user2 = arg; - return !strcmp(user->name, user2->name) ? CMP_MATCH : 0; + return !strcmp(user->name, user2->name) ? CMP_MATCH | CMP_STOP : 0; } /*! @@ -12194,7 +12194,7 @@ static int pvt_cmp_cb(void *obj, void *arg, int flags) * against a full frame or not ... */ return match(&pvt2->addr, pvt2->peercallno, pvt2->callno, pvt, - pvt2->frames_received) ? CMP_MATCH : 0; + pvt2->frames_received) ? CMP_MATCH | CMP_STOP : 0; } /*! \brief Load IAX2 module, load configuraiton ---*/ diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 804599c76..351a09782 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -1651,7 +1651,7 @@ static int peer_cmp_cb(void *obj, void *arg, int flags) { struct sip_peer *peer = obj, *peer2 = arg; - return !strcasecmp(peer->name, peer2->name) ? CMP_MATCH : 0; + return !strcasecmp(peer->name, peer2->name) ? CMP_MATCH | CMP_STOP : 0; } /*! @@ -1683,11 +1683,11 @@ static int peer_ipcmp_cb(void *obj, void *arg, int flags) if (!ast_test_flag(&peer->flags[0], SIP_INSECURE_PORT) && !ast_test_flag(&peer2->flags[0], SIP_INSECURE_PORT)) { if (peer->addr.sin_port == peer2->addr.sin_port) - return CMP_MATCH; + return CMP_MATCH | CMP_STOP; else return 0; } - return CMP_MATCH; + return CMP_MATCH | CMP_STOP; } /*! @@ -1707,7 +1707,7 @@ static int dialog_cmp_cb(void *obj, void *arg, int flags) { struct sip_pvt *pvt = obj, *pvt2 = arg; - return !strcasecmp(pvt->callid, pvt2->callid) ? CMP_MATCH : 0; + return !strcasecmp(pvt->callid, pvt2->callid) ? CMP_MATCH | CMP_STOP : 0; } static int temp_pvt_init(void *); |