Index: main/devicestate.c =================================================================== --- main/devicestate.c (revision 129629) +++ main/devicestate.c (working copy) @@ -299,6 +299,7 @@ char *device; struct state_change *change; char *tmp = NULL; + struct ast_channel *tmpchan; if (option_debug > 2) ast_log(LOG_DEBUG, "Notification of state change to be queued on device/channel %s\n", buf); @@ -326,8 +327,13 @@ * 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. + * + * Modifying to only do this check if we find the device name, as passed, + * in the channel list. This should cut out a large swath of extraneous + * device state events. */ - if (!norecurse && (tmp = strrchr(device, '-'))) { + if (!norecurse && (tmp = strrchr(device, '-')) && (tmpchan = ast_get_channel_by_name_locked(device))) { + ast_channel_unlock(tmpchan); *tmp = '\0'; __ast_device_state_changed_literal(device, 1); }