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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Sep 17 17:04:36 CDT 2013


Author: dlee
Date: Tue Sep 17 17:04:34 2013
New Revision: 399282

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=399282
Log:
taskprocessor performance tweaking

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=399282&r1=399281&r2=399282
==============================================================================
--- team/dlee/performance/main/taskprocessor.c (original)
+++ team/dlee/performance/main/taskprocessor.c Tue Sep 17 17:04:34 2013
@@ -360,8 +360,8 @@
 	char name[256];
 	int tcount;
 	unsigned long qsize;
-	unsigned long maxqsize;
-	unsigned long processed;
+	unsigned long maxqsize = 0;
+	unsigned long processed = 0;
 	struct ast_taskprocessor *p;
 	struct ao2_iterator i;
 
@@ -425,10 +425,9 @@
 	}
 	ast_debug(1, "destroying taskprocessor '%s'\n", t->name);
 	/* free it */
-	if (t->stats) {
-		ast_free(t->stats);
-		t->stats = NULL;
-	}
+	ast_free(t->stats);
+	t->stats = NULL;
+
 	ast_free((char *) t->name);
 	if (t->listener) {
 		/* This code should not be reached since the listener
@@ -447,7 +446,6 @@
 static struct tps_task *tps_taskprocessor_pop(struct ast_taskprocessor *tps)
 {
 	struct tps_task *task;
-	SCOPED_AO2LOCK(lock, tps);
 
 	if ((task = AST_LIST_REMOVE_HEAD(&tps->tps_queue, list))) {
 		tps->tps_queue_size--;
@@ -530,6 +528,7 @@
 		ast_log(LOG_WARNING, "failed to create taskprocessor stats for '%s'\n", name);
 		return NULL;
 	}
+
 	if (!(p->name = ast_strdup(name))) {
 		ao2_ref(p, -1);
 		return NULL;
@@ -666,15 +665,18 @@
 	int size;
 
 	ao2_lock(tps);
+	t = tps_taskprocessor_pop(tps);
+
+	/* Empty queue; return false */
+	if (!t) {
+		ao2_unlock(tps);
+		return 0;
+	}
 	tps->executing = 1;
 	ao2_unlock(tps);
 
-	t = tps_taskprocessor_pop(tps);
-
-	if (t) {
-		t->execute(t->datap);
-		tps_task_free(t);
-	}
+	t->execute(t->datap);
+	tps_task_free(t);
 
 	ao2_lock(tps);
 	/* We need to check size in the same critical section where we reset the
@@ -684,16 +686,14 @@
 	tps->executing = 0;
 	size = tps_taskprocessor_depth(tps);
 	/* If we executed a task, bump the stats */
-	if (t && tps->stats) {
-		tps->stats->_tasks_processed_count++;
-		if (size > tps->stats->max_qsize) {
-			tps->stats->max_qsize = size;
-		}
+	tps->stats->_tasks_processed_count++;
+	if (size > tps->stats->max_qsize) {
+		tps->stats->max_qsize = size;
 	}
 	ao2_unlock(tps);
 
 	/* If we executed a task, check for the transition to empty */
-	if (t && size == 0 && tps->listener->callbacks->emptied) {
+	if (size == 0 && tps->listener->callbacks->emptied) {
 		tps->listener->callbacks->emptied(tps->listener);
 	}
 	return size > 0;




More information about the asterisk-commits mailing list