diff options
author | Richard Mudgett <rmudgett@digium.com> | 2012-01-09 21:56:29 +0000 |
---|---|---|
committer | Richard Mudgett <rmudgett@digium.com> | 2012-01-09 21:56:29 +0000 |
commit | 64d1b247c407de2af029392a6c32a99bf11c7ded (patch) | |
tree | f7738eb1365416dd509c17b6822bfd90d10f7553 | |
parent | a2a3b3ee4bac7f2fcef2481c83a0741e5fc699ad (diff) |
Fix joinable thread terminating without joiner memory leak in chan_iax.c.
The iax2_process_thread() can exit without anyone waiting to join the
thread. If noone is waiting to join the thread then a large memory leak
occurs.
* Made iax2_process_thread() deatach itself if nobody is waiting to join
the thread.
(closes issue ASTERISK-17339)
Reported by: Tzafrir Cohen
Patches:
asterisk-1.8.4.4-chan_iax2-detach-thread-on-non-stop-exit.patch (license #5617) patch uploaded by Alex Villacis Lasso (modified)
(closes issue ASTERISK-17825)
Reported by: wangjin
........
Merged revisions 350220 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
Merged revisions 350221 from http://svn.asterisk.org/svn/asterisk/branches/10
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@350222 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r-- | channels/chan_iax2.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 546f2070b..34d6536f9 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -11839,7 +11839,8 @@ static void *iax2_process_thread(void *data) handle_deferred_full_frames(thread); } - /*!\note For some reason, idle threads are exiting without being removed + /*! + * \note For some reason, idle threads are exiting without being removed * from an idle list, which is causing memory corruption. Forcibly remove * it from the list, if it's there. */ @@ -11851,6 +11852,11 @@ static void *iax2_process_thread(void *data) AST_LIST_REMOVE(&dynamic_list, thread, list); AST_LIST_UNLOCK(&dynamic_list); + if (!thread->stop) { + /* Nobody asked me to stop so nobody is waiting to join me. */ + pthread_detach(pthread_self()); + } + /* I am exiting here on my own volition, I need to clean up my own data structures * Assume that I am no longer in any of the lists (idle, active, or dynamic) */ |