[asterisk-commits] kpfleming: branch 1.4 r49581 - /branches/1.4/channels/chan_iax2.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Jan 4 16:50:16 MST 2007


Author: kpfleming
Date: Thu Jan  4 17:50:15 2007
New Revision: 49581

URL: http://svn.digium.com/view/asterisk?view=rev&rev=49581
Log:
create the IAX2 processing threads as background threads so they will use smaller stacks
when we create a dynamic thread, put it on the dynamic_list right away so we don't lose track of it

Modified:
    branches/1.4/channels/chan_iax2.c

Modified: branches/1.4/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/chan_iax2.c?view=diff&rev=49581&r1=49580&r2=49581
==============================================================================
--- branches/1.4/channels/chan_iax2.c (original)
+++ branches/1.4/channels/chan_iax2.c Thu Jan  4 17:50:15 2007
@@ -855,24 +855,21 @@
 	/* If no idle thread is available from the regular list, try dynamic */
 	if (thread == NULL) {
 		AST_LIST_LOCK(&dynamic_list);
-		thread = AST_LIST_FIRST(&dynamic_list);
-		if (thread != NULL) {
-			AST_LIST_REMOVE(&dynamic_list, thread, list);
-		}
+		thread = AST_LIST_REMOVE_HEAD(&dynamic_list, list);
 		/* Make sure we absolutely have a thread... if not, try to make one if allowed */
 		if (thread == NULL && iaxmaxthreadcount > iaxdynamicthreadcount) {
 			/* We need to MAKE a thread! */
-			thread = ast_calloc(1, sizeof(*thread));
-			if (thread != NULL) {
+			if ((thread = ast_calloc(1, sizeof(*thread)))) {
 				thread->threadnum = iaxdynamicthreadcount;
 				thread->type = IAX_TYPE_DYNAMIC;
 				ast_mutex_init(&thread->lock);
 				ast_cond_init(&thread->cond, NULL);
-				if (ast_pthread_create(&thread->threadid, NULL, iax2_process_thread, thread)) {
+				if (ast_pthread_create_background(&thread->threadid, NULL, iax2_process_thread, thread)) {
 					free(thread);
 					thread = NULL;
 				} else {
 					/* All went well and the thread is up, so increment our count */
+					AST_LIST_INSERT_TAIL(&dynamic_list, thread, list);
 					iaxdynamicthreadcount++;
 				}
 			}
@@ -8110,7 +8107,7 @@
 			thread->threadnum = ++threadcount;
 			ast_mutex_init(&thread->lock);
 			ast_cond_init(&thread->cond, NULL);
-			if (ast_pthread_create(&thread->threadid, NULL, iax2_process_thread, thread)) {
+			if (ast_pthread_create_background(&thread->threadid, NULL, iax2_process_thread, thread)) {
 				ast_log(LOG_WARNING, "Failed to create new thread!\n");
 				free(thread);
 				thread = NULL;



More information about the asterisk-commits mailing list