--- apps/app_queue.c 2013-11-11 10:35:22.000000000 -0500 +++ apps/app_queue.c 2014-03-10 09:52:54.140292460 -0400 @@ -1145,6 +1145,7 @@ char state_exten[AST_MAX_EXTENSION]; /*!< Extension to get state from (if using hint) */ char state_context[AST_MAX_CONTEXT]; /*!< Context to use when getting state (if using hint) */ char state_interface[AST_CHANNEL_NAME]; /*!< Technology/Location from which to read devicestate changes */ + int state_id; /*!< Extension state callback id (if using hint) */ char membername[80]; /*!< Member name to use in queue logs */ int penalty; /*!< Are we a last resort? */ int calls; /*!< Number of calls serviced by this member */ @@ -2463,6 +2464,15 @@ mem->queuepos = ao2_container_count(queue->members); ao2_link(queue->members, mem); ao2_unlock(queue->members); + + /* If a hint is used as the 'state_interface', make sure to subscribe to it + * explicitly so that on the off chance that the hint is dynamic, it will + * not disappear after a 'dialplan reload' since it has at least one watcher */ + if (!ast_strlen_zero(mem->state_exten)) { + mem->state_id = ast_extension_state_add(mem->state_context, mem->state_exten, extension_state_cb, NULL); + } else { + mem->state_id = -1; + } } /*! \internal @@ -2473,6 +2483,12 @@ */ static void member_remove_from_queue(struct call_queue *queue, struct member *mem) { + /* If we previously had to subscribe to a hint, make sure to unsubscribe as + * the member is now being removed */ + if (mem->state_id != -1) { + ast_extension_state_del(mem->state_id, extension_state_cb); + } + ao2_lock(queue->members); queue_member_follower_removal(queue, mem); ao2_unlink(queue->members, mem);