Index: main/channel.c =================================================================== --- main/channel.c (revision 133569) +++ main/channel.c (working copy) @@ -1277,7 +1277,7 @@ struct ast_frame *f; struct varshead *headp; struct ast_datastore *datastore = NULL; - char name[AST_CHANNEL_NAME]; + char name[AST_CHANNEL_NAME], *dashptr; headp=&chan->varshead; @@ -1310,6 +1310,9 @@ sched_context_destroy(chan->sched); ast_copy_string(name, chan->name, sizeof(name)); + if ((dashptr = strrchr(name, '-'))) { + *dashptr = '\0'; + } /* Stop monitoring */ if (chan->monitor) @@ -4086,12 +4089,18 @@ int ast_setstate(struct ast_channel *chan, enum ast_channel_state state) { int oldstate = chan->_state; + char name[AST_CHANNEL_NAME], *dashptr; if (oldstate == state) return 0; + ast_copy_string(name, chan->name, sizeof(name)); + if ((dashptr = strrchr(name, '-'))) { + *dashptr = '\0'; + } + chan->_state = state; - ast_device_state_changed_literal(chan->name); + ast_device_state_changed_literal(name); /* setstate used to conditionally report Newchannel; this is no more */ manager_event(EVENT_FLAG_CALL, "Newstate", Index: main/devicestate.c =================================================================== --- main/devicestate.c (revision 133569) +++ main/devicestate.c (working copy) @@ -457,16 +457,12 @@ devstate_event(device, state, CACHE_OFF); } -static int __ast_devstate_changed_literal(enum ast_device_state state, char *buf, int norecurse) +int ast_devstate_changed_literal(enum ast_device_state state, const char *device) { - char *device; struct state_change *change; - char *tmp = NULL; - ast_debug(3, "Notification of state change to be queued on device/channel %s\n", buf); + ast_debug(3, "Notification of state change to be queued on device/channel %s\n", device); - device = buf; - if (state != AST_DEVICE_UNKNOWN) { devstate_event(device, state, CACHE_ON); } else if (change_thread == AST_PTHREADT_NULL || !(change = ast_calloc(1, sizeof(*change) + strlen(device)))) { @@ -482,37 +478,12 @@ AST_LIST_UNLOCK(&state_changes); } - /* The problem with this API is that a device may be called with the unique - * identifier appended or not, but it's separated from the channel name - * with a '-', which is also a legitimate character in a channel name. So, - * we have to force both names to get their names checked for state changes - * to ensure that the right one gets notified. Not a huge performance hit, - * but it might could be fixed by an enterprising programmer in trunk. - */ - if (!norecurse && (tmp = strrchr(device, '-'))) { - *tmp = '\0'; - __ast_devstate_changed_literal(state, device, 1); - } - return 1; } -int ast_devstate_changed_literal(enum ast_device_state state, const char *dev) -{ - char *buf; - - buf = ast_strdupa(dev); - - return __ast_devstate_changed_literal(state, buf, 0); -} - int ast_device_state_changed_literal(const char *dev) { - char *buf; - - buf = ast_strdupa(dev); - - return __ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, buf, 0); + return ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, dev); } int ast_devstate_changed(enum ast_device_state state, const char *fmt, ...) @@ -524,7 +495,7 @@ vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); - return __ast_devstate_changed_literal(state, buf, 0); + return ast_devstate_changed_literal(state, buf); } /*! \brief Accept change notification, add it to change queue */ @@ -537,7 +508,7 @@ vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); - return __ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, buf, 0); + return ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, buf); } /*! \brief Go through the dev state change queue and update changes in the dev state thread */