mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 20:20:07 +00:00
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:
35
main/utils.c
35
main/utils.c
@@ -2833,3 +2833,38 @@ int __ast_fd_set_flags(int fd, int flags, enum ast_fd_flag_operation op,
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief A thread local indicating whether the current thread is a user interface.
|
||||
*/
|
||||
AST_THREADSTORAGE(thread_user_interface_tl);
|
||||
|
||||
int ast_thread_user_interface_set(int is_user_interface)
|
||||
{
|
||||
int *thread_user_interface;
|
||||
|
||||
thread_user_interface = ast_threadstorage_get(
|
||||
&thread_user_interface_tl, sizeof(*thread_user_interface));
|
||||
if (thread_user_interface == NULL) {
|
||||
ast_log(LOG_ERROR, "Error setting user interface status for current thread\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
*thread_user_interface = !!is_user_interface;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ast_thread_is_user_interface(void)
|
||||
{
|
||||
int *thread_user_interface;
|
||||
|
||||
thread_user_interface = ast_threadstorage_get(
|
||||
&thread_user_interface_tl, sizeof(*thread_user_interface));
|
||||
if (thread_user_interface == NULL) {
|
||||
ast_log(LOG_ERROR, "Error checking thread's user interface status\n");
|
||||
/* On error, assume that we are not a user interface thread */
|
||||
return 0;
|
||||
}
|
||||
|
||||
return *thread_user_interface;
|
||||
}
|
||||
|
Reference in New Issue
Block a user