Prevent Newchannel manager events for dummy channels.

No Newchannel manager event will be fired for channels that are
allocated to not match a registered technology type. Thus bogus
channels allocated solely for variable substitution or CDR
operations do not result in a Newchannel event.

(closes issue #16957)
Reported by: atis

Review: https://reviewboard.asterisk.org/r/601



git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@259018 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.4
Mark Michelson 16 years ago
parent bb48f80e58
commit a06794cf7a

@ -714,6 +714,7 @@ struct ast_channel *ast_channel_alloc(int needqueue, int state, const char *cid_
int flags; int flags;
struct varshead *headp; struct varshead *headp;
va_list ap1, ap2; va_list ap1, ap2;
char *tech;
/* If shutting down, don't allocate any new channels */ /* If shutting down, don't allocate any new channels */
if (shutting_down) { if (shutting_down) {
@ -814,6 +815,7 @@ alertpipe_failed:
tmp->cid.cid_num = ast_strdup(cid_num); tmp->cid.cid_num = ast_strdup(cid_num);
if (!ast_strlen_zero(name_fmt)) { if (!ast_strlen_zero(name_fmt)) {
char *slash;
/* Almost every channel is calling this function, and setting the name via the ast_string_field_build() call. /* Almost every channel is calling this function, and setting the name via the ast_string_field_build() call.
* And they all use slightly different formats for their name string. * And they all use slightly different formats for their name string.
* This means, to set the name here, we have to accept variable args, and call the string_field_build from here. * This means, to set the name here, we have to accept variable args, and call the string_field_build from here.
@ -826,6 +828,10 @@ alertpipe_failed:
ast_string_field_build_va(tmp, name, name_fmt, ap1, ap2); ast_string_field_build_va(tmp, name, name_fmt, ap1, ap2);
va_end(ap1); va_end(ap1);
va_end(ap2); va_end(ap2);
tech = ast_strdupa(tmp->name);
if ((slash = strchr(tech, '/'))) {
*slash = '\0';
}
} }
/* Reminder for the future: under what conditions do we NOT want to track cdrs on channels? */ /* Reminder for the future: under what conditions do we NOT want to track cdrs on channels? */
@ -880,7 +886,7 @@ alertpipe_failed:
* proper and correct place to make this call, but you sure do have to pass * proper and correct place to make this call, but you sure do have to pass
* a lot of data into this func to do it here! * a lot of data into this func to do it here!
*/ */
if (!ast_strlen_zero(name_fmt)) { if (ast_get_channel_tech(tech)) {
manager_event(EVENT_FLAG_CALL, "Newchannel", manager_event(EVENT_FLAG_CALL, "Newchannel",
"Channel: %s\r\n" "Channel: %s\r\n"
"State: %s\r\n" "State: %s\r\n"

Loading…
Cancel
Save