[asterisk-commits] trunk r30271 - /trunk/channels/chan_iax2.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Thu May 25 09:14:18 MST 2006
Author: file
Date: Thu May 25 11:14:17 2006
New Revision: 30271
URL: http://svn.digium.com/view/asterisk?rev=30271&view=rev
Log:
Safely traverse the thread lists and wait until each thread is done before moving on to the next.
Modified:
trunk/channels/chan_iax2.c
Modified: trunk/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_iax2.c?rev=30271&r1=30270&r2=30271&view=diff
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Thu May 25 11:14:17 2006
@@ -7732,7 +7732,6 @@
ast_mutex_destroy(&thread->lock);
ast_cond_destroy(&thread->cond);
free(thread);
- thread = NULL;
return NULL;
}
@@ -8642,7 +8641,6 @@
AST_LIST_TRAVERSE(&peers, peer, entry)
ast_set_flag(peer, IAX_DELME);
AST_LIST_UNLOCK(&peers);
-
}
static void destroy_user(struct iax2_user *user)
@@ -9681,6 +9679,7 @@
static int __unload_module(void)
{
+ pthread_t threadid = AST_PTHREADT_NULL;
struct iax2_thread *thread = NULL;
int x;
@@ -9700,24 +9699,36 @@
/* Call for all threads to halt */
AST_LIST_LOCK(&idle_list);
- AST_LIST_TRAVERSE(&idle_list, thread, list) {
+ AST_LIST_TRAVERSE_SAFE_BEGIN(&idle_list, thread, list) {
+ AST_LIST_REMOVE_CURRENT(&idle_list, list);
+ threadid = thread->threadid;
thread->halt = 1;
signal_condition(&thread->lock, &thread->cond);
- }
+ pthread_join(threadid, NULL);
+ }
+ AST_LIST_TRAVERSE_SAFE_END
AST_LIST_UNLOCK(&idle_list);
AST_LIST_LOCK(&active_list);
- AST_LIST_TRAVERSE(&active_list, thread, list) {
+ AST_LIST_TRAVERSE_SAFE_BEGIN(&active_list, thread, list) {
+ AST_LIST_REMOVE_CURRENT(&active_list, list);
+ threadid = thread->threadid;
thread->halt = 1;
signal_condition(&thread->lock, &thread->cond);
- }
+ pthread_join(threadid, NULL);
+ }
+ AST_LIST_TRAVERSE_SAFE_END
AST_LIST_UNLOCK(&active_list);
AST_LIST_LOCK(&dynamic_list);
- AST_LIST_TRAVERSE(&dynamic_list, thread, list) {
+ AST_LIST_TRAVERSE_SAFE_BEGIN(&dynamic_list, thread, list) {
+ AST_LIST_REMOVE_CURRENT(&dynamic_list, list);
+ threadid = thread->threadid;
thread->halt = 1;
signal_condition(&thread->lock, &thread->cond);
+ pthread_join(threadid, NULL);
}
+ AST_LIST_TRAVERSE_SAFE_END
AST_LIST_UNLOCK(&dynamic_list);
ast_netsock_release(netsock);
More information about the asterisk-commits
mailing list