[asterisk-dev] [Code Review] Implement ast_channel_search_locked to expensive per-notify channel walk in chan_sip

Brian Degenhardt bmd at digium.com
Tue Nov 4 17:12:16 CST 2008


Russell, at astridevcon we talked about CEL's method of seeing if a
linkedid exists when a channel is destroyed, and how it needs to search
all channels.  Would this be a reasonable substitute to accomplish that
task?

Murf was going to do the whole hashtab thing, but this might be good enough.

What do you guys think?  Here's the current function, to refresh your
memory:

/* called whenever a channel is destroyed or a linkedid is changed to
potentially emit a CEL_LINKEDID_END event */
void ast_cel_check_retire_linkedid(const struct ast_channel *chan)
{
    int found=0;
    struct ast_channel *tmp = NULL;
    const char *linkedid = chan->linkedid;

    /* make sure we need to do all this work */
    if (!ast_strlen_zero(linkedid) && track_event(CEL_LINKEDID_END)) {
        while ((tmp = ast_channel_walk_locked(tmp))) {
            if (tmp != chan && tmp->linkedid && 0==strcmp(linkedid,
tmp->linkedid)) {
                found=1;
                ast_channel_unlock(tmp);
                break;
            }
            ast_channel_unlock(tmp);
        }

        if (!found) {
            ast_cel_report_event(chan, CEL_LINKEDID_END, NULL, NULL, NULL);
        }
    }
}



Sean Bright wrote:
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://reviewboard.digium.com/r/28/
> -----------------------------------------------------------
> 
> Review request for Asterisk Developers.
> 
> 
> Summary
> -------
> 
> Based on some feedback from my chan_sip commit earlier today from oej, kpfleming, and russellb, implement ast_channel_search_locked which iterates over the channel list, while locked, and calls a filter callback to determine if this is the channel we are looking for.  If so, we lock and return, otherwise we return NULL.
> 
> Patch also includes the change required to chan_sip.c to use the new function.
> 
> 
> Diffs
> -----
> 
>   /trunk/channels/chan_sip.c 154189 
>   /trunk/include/asterisk/channel.h 154189 
>   /trunk/main/channel.c 154189 
> 
> Diff: http://reviewboard.digium.com/r/28/diff
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Sean
> 
> 
> _______________________________________________
> --Bandwidth and Colocation Provided by http://www.api-digital.com--
> 
> asterisk-dev mailing list
> To UNSUBSCRIBE or update options visit:
>    http://lists.digium.com/mailman/listinfo/asterisk-dev





More information about the asterisk-dev mailing list