continue;
}
+ /* Set this thread's id as the control thread id so that any
+ new commands can signal out of this wait */
+ control_set_thread(control, pthread_self());
r = ast_waitfor(chan, MAX_WAIT_MS);
+ control_set_thread(control, AST_PTHREADT_NULL);
if (r < 0) {
ast_debug(3, "%s: Poll error\n",
* The name of the next Stasis application to move to.
*/
char *next_app;
+ /*!
+ * The thread currently blocking on the channel.
+ */
+ pthread_t control_thread;
/*!
* The list of arguments to pass to StasisStart when moving to another app.
*/
control->next_app = NULL;
AST_VECTOR_INIT(&control->next_app_args, 0);
+ control_set_thread(control, AST_PTHREADT_NULL);
+
return control;
}
ao2_unlock(control->command_queue);
}
+void control_set_thread(struct stasis_app_control *control, pthread_t threadid)
+{
+ ao2_lock(control->command_queue);
+ control->control_thread = threadid;
+ ao2_unlock(control->command_queue);
+}
+
/*!
* \internal
* \brief Checks to make sure each rule in the given list passes.
ao2_link_flags(control->command_queue, command, OBJ_NOLOCK);
ast_cond_signal(&control->wait_cond);
+
+ if (control->control_thread != AST_PTHREADT_NULL) {
+ /* if the control thread is waiting on the channel, send the SIGURG
+ to let it know there is a new command */
+ pthread_kill(control->control_thread, SIGURG);
+ }
+
ao2_unlock(control->command_queue);
return command;
*/
void control_flush_queue(struct stasis_app_control *control);
+/*!
+ * \brief set the control's thread id
+ * \since 18
+ *
+ * \param control Control object on which to set the thread id.
+ * \param threadid id to set
+ */
+void control_set_thread(struct stasis_app_control *control, pthread_t threadid);
+
/*!
* \brief Dispatch all commands enqueued to this control.
*