From aa8405923a81dd8b7eb3437d0237b85893b09337 Mon Sep 17 00:00:00 2001
From: Richard Mudgett <rmudgett@digium.com>
Date: Thu, 5 Sep 2013 17:29:24 +0000
Subject: [PATCH] chan_iax2: Fix stray reference to worker thread idle_list.

* Fix stray reference to idle_list in cleanup_thread_list().  This may be
the reason for the note in iax2_process_thread() about threads not being
removed from the task lists.

* Move cleanup_thread_list(&idle_list) to after the other lists are
cleaned up.
........

Merged revisions 398416 from http://svn.asterisk.org/svn/asterisk/branches/1.8


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/11@398417 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 channels/chan_iax2.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 05e88b9b64..52430b1466 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -11985,9 +11985,9 @@ static void *iax2_process_thread(void *data)
 	}
 
 	/*!
-	 * \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.
+	 * \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.
 	 */
 	AST_LIST_LOCK(&idle_list);
 	AST_LIST_REMOVE(&idle_list, thread, list);
@@ -14569,7 +14569,7 @@ static void cleanup_thread_list(void *head)
 	struct iax2_thread *thread;
 
 	AST_LIST_LOCK(list_head);
-	while ((thread = AST_LIST_REMOVE_HEAD(&idle_list, list))) {
+	while ((thread = AST_LIST_REMOVE_HEAD(list_head, list))) {
 		pthread_t thread_id = thread->threadid;
 
 		thread->stop = 1;
@@ -14612,9 +14612,9 @@ static int __unload_module(void)
 	}
 
 	/* Call for all threads to halt */
-	cleanup_thread_list(&idle_list);
 	cleanup_thread_list(&active_list);
 	cleanup_thread_list(&dynamic_list);
+	cleanup_thread_list(&idle_list);
 
 	ast_netsock_release(netsock);
 	ast_netsock_release(outsock);
-- 
GitLab