[asterisk-commits] dlee: branch dlee/performance r399646 - /team/dlee/performance/main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Sep 23 16:30:16 CDT 2013


Author: dlee
Date: Mon Sep 23 16:30:14 2013
New Revision: 399646

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=399646
Log:
Attempt at self-destructing task processors

Modified:
    team/dlee/performance/main/taskprocessor.c

Modified: team/dlee/performance/main/taskprocessor.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/performance/main/taskprocessor.c?view=diff&rev=399646&r1=399645&r2=399646
==============================================================================
--- team/dlee/performance/main/taskprocessor.c (original)
+++ team/dlee/performance/main/taskprocessor.c Mon Sep 23 16:30:14 2013
@@ -144,6 +144,7 @@
 	int dead;
 };
 
+static void default_listener_pvt_destroy(struct default_taskprocessor_listener_pvt *pvt);
 
 static void default_tps_wake_up(struct default_taskprocessor_listener_pvt *pvt, int should_die)
 {
@@ -179,6 +180,15 @@
 			dead = default_tps_idle(pvt);
 		}
 	}
+
+	/* Drain the rest of the queue */
+	while (ast_taskprocessor_execute(tps)) {
+		/* No-op */
+	}
+
+	/* Destroy the private data section */
+	default_listener_pvt_destroy(pvt);
+	listener->user_data = NULL;
 	return NULL;
 }
 
@@ -215,9 +225,13 @@
 {
 	struct default_taskprocessor_listener_pvt *pvt = listener->user_data;
 	default_tps_wake_up(pvt, 1);
-	pthread_join(pvt->poll_thread, NULL);
+	if (pthread_self() == pvt->poll_thread) {
+		/* Shutting self down. Yay! */
+		pthread_detach(pvt->poll_thread);
+	} else {
+		pthread_join(pvt->poll_thread, NULL);
+	}
 	pvt->poll_thread = AST_PTHREADT_NULL;
-	default_listener_pvt_destroy(pvt);
 }
 
 static const struct ast_taskprocessor_listener_callbacks default_listener_callbacks = {




More information about the asterisk-commits mailing list