mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-03 19:16:46 +00:00
chan_sip: Fix deadlock of monlock between unload_module and do_monitor
Release monlock before calling pthread_join. This ensures do_monitor cannot freeze by locking monlock during module unload. (closes issue ASTERISK-21406) Reported by: Corey Farrell Review: https://reviewboard.asterisk.org/r/3284/ ........ Merged revisions 410224 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 410225 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/12@410226 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -34648,12 +34648,16 @@ static int unload_module(void)
|
|||||||
|
|
||||||
ast_mutex_lock(&monlock);
|
ast_mutex_lock(&monlock);
|
||||||
if (monitor_thread && (monitor_thread != AST_PTHREADT_STOP) && (monitor_thread != AST_PTHREADT_NULL)) {
|
if (monitor_thread && (monitor_thread != AST_PTHREADT_STOP) && (monitor_thread != AST_PTHREADT_NULL)) {
|
||||||
pthread_cancel(monitor_thread);
|
pthread_t th = monitor_thread;
|
||||||
pthread_kill(monitor_thread, SIGURG);
|
monitor_thread = AST_PTHREADT_STOP;
|
||||||
pthread_join(monitor_thread, NULL);
|
pthread_cancel(th);
|
||||||
}
|
pthread_kill(th, SIGURG);
|
||||||
|
ast_mutex_unlock(&monlock);
|
||||||
|
pthread_join(th, NULL);
|
||||||
|
} else {
|
||||||
monitor_thread = AST_PTHREADT_STOP;
|
monitor_thread = AST_PTHREADT_STOP;
|
||||||
ast_mutex_unlock(&monlock);
|
ast_mutex_unlock(&monlock);
|
||||||
|
}
|
||||||
|
|
||||||
/* Destroy all the dialogs and free their memory */
|
/* Destroy all the dialogs and free their memory */
|
||||||
i = ao2_iterator_init(dialogs, 0);
|
i = ao2_iterator_init(dialogs, 0);
|
||||||
|
Reference in New Issue
Block a user