autoservice: Don't start channel autoservice if the thread is a user interface.

Executing dialplan functions from either AMI or ARI by getting a variable
could place the channel into autoservice.  However, these user interface
threads do not handle the channel's media so we wind up with two threads
attempting to handle the media.

There can be one and only one thread handling a channel's media at a time.
Otherwise, we don't know which thread is going to handle the media frames.

ASTERISK-27625

Change-Id: If2dc94ce15ddabf923ed1e2a65ea0ef56e013e49
This commit is contained in:
Richard Mudgett
2018-06-18 18:04:54 -05:00
parent 99f439dc01
commit 5d34ca5b33
4 changed files with 80 additions and 0 deletions

View File

@@ -195,6 +195,13 @@ int ast_autoservice_start(struct ast_channel *chan)
int res = 0;
struct asent *as;
if (ast_thread_is_user_interface()) {
/* User interface threads do not handle channel media. */
ast_debug(1, "Thread is a user interface, not putting channel %s into autoservice\n",
ast_channel_name(chan));
return 0;
}
AST_LIST_LOCK(&aslist);
AST_LIST_TRAVERSE(&aslist, as, list) {
if (as->chan == chan) {
@@ -256,6 +263,13 @@ int ast_autoservice_stop(struct ast_channel *chan)
struct ast_frame *f;
int chan_list_state;
if (ast_thread_is_user_interface()) {
/* User interface threads do not handle channel media. */
ast_debug(1, "Thread is a user interface, not removing channel %s from autoservice\n",
ast_channel_name(chan));
return 0;
}
AST_LIST_LOCK(&aslist);
/* Save the autoservice channel list state. We _must_ verify that the channel