aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
authorseanbright <seanbright@f38db490-d61c-443f-a65b-d21fe96a405b>2008-11-04 23:23:39 +0000
committerseanbright <seanbright@f38db490-d61c-443f-a65b-d21fe96a405b>2008-11-04 23:23:39 +0000
commit1a38e697dbf28ea03b5e1801893a250fababbeab (patch)
treecc80e865574edf9aedd9298a568c9b998b118374 /channels
parentd6530734b8fc799ffb1ce764716bc5d02b86afde (diff)
Introduce a new API call ast_channel_search_locked, which iterates through the
channel list calling a caller-defined callback. The callback returns non-zero if a match is found. This should speed up some of the code that I committed earlier today in chan_sip (which is also updated by this commit). Reviewed by russellb and kpfleming via ReviewBoard: http://reviewboard.digium.com/r/28/ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@154429 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_sip.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 36a027ed3..4ebd970dc 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -10037,19 +10037,21 @@ static int transmit_state_notify(struct sip_pvt *p, int state, int full, int tim
callee must be dialing the same extension that is being monitored. Simply dialing
the hint'd device is not sufficient. */
if (global_notifycid) {
- struct ast_channel *caller = NULL;
-
- while ((caller = ast_channel_walk_locked(caller))) {
- if (caller->pbx &&
- (!strcasecmp(caller->macroexten, p->exten) || !strcasecmp(caller->exten, p->exten)) &&
- !strcasecmp(caller->context, p->context)) {
- local_display = ast_strdupa(caller->cid.cid_name);
- local_target = ast_strdupa(caller->cid.cid_num);
- ast_channel_unlock(caller);
- break;
- }
+ auto int find_calling_channel(struct ast_channel *c);
+ int find_calling_channel(struct ast_channel *c) {
+ return (c->pbx &&
+ (!strcasecmp(c->macroexten, p->exten) || !strcasecmp(c->exten, p->exten)) &&
+ !strcasecmp(c->context, p->context));
+ }
+
+ struct ast_channel *caller = ast_channel_search_locked(find_calling_channel);
+
+ if (caller) {
+ local_display = ast_strdupa(caller->cid.cid_name);
+ local_target = ast_strdupa(caller->cid.cid_num);
ast_channel_unlock(caller);
- }
+ caller = NULL;
+ }
}
/* We create a fake call-id which the phone will send back in an INVITE