--- apps/app_queue.c 2014-03-10 10:51:49.116283966 -0400 +++ apps/app_queue.c 2014-03-10 10:54:32.015735175 -0400 @@ -1034,6 +1034,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[80]; /*!< 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 */ @@ -2150,6 +2151,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 @@ -2160,6 +2170,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);