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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Sep 18 14:33:56 CDT 2013


Author: dlee
Date: Wed Sep 18 14:33:54 2013
New Revision: 399401

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=399401
Log:
Don't destroy a task processor while tasks are in the queue

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=399401&r1=399400&r2=399401
==============================================================================
--- team/dlee/performance/main/taskprocessor.c (original)
+++ team/dlee/performance/main/taskprocessor.c Wed Sep 18 14:33:54 2013
@@ -382,6 +382,8 @@
 	ast_cli(a->fd, "\n\t+----- Processor -----+--- Processed ---+- In Queue -+- Max Depth -+");
 	i = ao2_iterator_init(tps_singletons, 0);
 	while ((p = ao2_iterator_next(&i))) {
+		ast_assert(p->stats != NULL);
+
 		ast_copy_string(name, p->name, sizeof(name));
 		qsize = p->tps_queue_size;
 		maxqsize = p->stats->max_qsize;
@@ -650,6 +652,7 @@
 		return -1;
 	}
 	ao2_lock(tps);
+	ao2_ref(tps, +1); /* Let's say the queued task has a reference */
 	AST_LIST_INSERT_TAIL(&tps->tps_queue, t, list);
 	previous_size = tps->tps_queue_size++;
 	/* The currently executing task counts as still in queue */
@@ -663,6 +666,8 @@
 {
 	struct tps_task *t;
 	int size;
+
+	ast_assert(tps->stats != NULL);
 
 	ao2_lock(tps);
 	t = tps_taskprocessor_pop(tps);
@@ -696,5 +701,7 @@
 	if (size == 0 && tps->listener->callbacks->emptied) {
 		tps->listener->callbacks->emptied(tps->listener);
 	}
+
+	ao2_ref(tps, -1); /* task no longer has a reference */
 	return size > 0;
 }




More information about the asterisk-commits mailing list