Resolve some errors produced during module unload of chan_iax2.
authorRussell Bryant <russell@russellbryant.com>
Wed, 23 Jun 2010 23:09:28 +0000 (23:09 +0000)
committerRussell Bryant <russell@russellbryant.com>
Wed, 23 Jun 2010 23:09:28 +0000 (23:09 +0000)
commit450f4ff2ee5e525da31fc14e909dbcc492ac2ea5
treeb9e1a669ee14f9e5cdd168a17b79a0e5277e3930
parentcb22af3ec5e9f6bb07e714406e545d28bc451764
Resolve some errors produced during module unload of chan_iax2.

The external test suite stops Asterisk using the "core stop gracefully" command.
The logs from the tests show that there are a number of problems with Asterisk
trying to cleanly shut down.  This patch addresses the following type of error
that comes from chan_iax2:

[Jun 22 16:58:11] ERROR[29884]: lock.c:129 __ast_pthread_mutex_destroy:
                chan_iax2.c line 11371 (iax2_process_thread_cleanup):
                Error destroying mutex &thread->lock: Device or resource busy

For an example in the context of a build, see:

http://bamboo.asterisk.org/browse/AST-TRUNK-739/log

The primary purpose of this patch is to change the thread pool shutdown
procedure to be more explicit to ensure that the thread exits from a point
where it is not holding a lock.  While testing that, I encountered various
crashes due to the order of operations in unload_module() being problematic.
I reordered some things there, as well.

Review: https://reviewboard.asterisk.org/r/736/

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@272370 65c4cc65-6c06-0410-ace0-fbb531ad65f3
channels/chan_iax2.c