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

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


Author: dlee
Date: Mon Sep 23 16:41:27 2013
New Revision: 399647

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=399647
Log:
Fix self-shutdown refcounting problem

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=399647&r1=399646&r2=399647
==============================================================================
--- team/dlee/performance/main/taskprocessor.c (original)
+++ team/dlee/performance/main/taskprocessor.c Mon Sep 23 16:41:27 2013
@@ -114,7 +114,7 @@
 static int tps_cmp_cb(void *obj, void *arg, int flags);
 
 /*! \brief The task processing function executed by a taskprocessor */
-static void *tps_processing_function(void *data);
+static void *default_tps_processing_function(void *data);
 
 /*! \brief Destroy the taskprocessor when its refcount reaches zero */
 static void tps_taskprocessor_destroy(void *tps);
@@ -168,7 +168,7 @@
  * \brief Function that processes tasks in the taskprocessor
  * \internal
  */
-static void *tps_processing_function(void *data)
+static void *default_tps_processing_function(void *data)
 {
 	struct ast_taskprocessor_listener *listener = data;
 	struct ast_taskprocessor *tps = listener->tps;
@@ -189,6 +189,10 @@
 	/* Destroy the private data section */
 	default_listener_pvt_destroy(pvt);
 	listener->user_data = NULL;
+
+	/* Get rid of the shutdown ref */
+	ao2_ref(tps, -1);
+
 	return NULL;
 }
 
@@ -196,7 +200,7 @@
 {
 	struct default_taskprocessor_listener_pvt *pvt = listener->user_data;
 
-	if (ast_pthread_create(&pvt->poll_thread, NULL, tps_processing_function, listener)) {
+	if (ast_pthread_create(&pvt->poll_thread, NULL, default_tps_processing_function, listener)) {
 		return -1;
 	}
 
@@ -224,6 +228,9 @@
 static void default_listener_shutdown(struct ast_taskprocessor_listener *listener)
 {
 	struct default_taskprocessor_listener_pvt *pvt = listener->user_data;
+
+	/* Keep tps around long enough for the thread to exit */
+	ao2_ref(listener->tps, +1);
 	default_tps_wake_up(pvt, 1);
 	if (pthread_self() == pvt->poll_thread) {
 		/* Shutting self down. Yay! */




More information about the asterisk-commits mailing list