[asterisk-commits] dhubbard: branch group/taskprocessors r111532 - in /team/group/taskprocessors...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Mar 27 17:46:57 CDT 2008


Author: dhubbard
Date: Thu Mar 27 17:46:56 2008
New Revision: 111532

URL: http://svn.digium.com/view/asterisk?view=rev&rev=111532
Log:
use ast_debug() instead of ast_log(LOG_DEBUG ...); lock protect _poll_thread_run

Modified:
    team/group/taskprocessors/apps/app_voicemail.c
    team/group/taskprocessors/include/asterisk/taskprocessor.h
    team/group/taskprocessors/main/taskprocessor.c

Modified: team/group/taskprocessors/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/group/taskprocessors/apps/app_voicemail.c?view=diff&rev=111532&r1=111531&r2=111532
==============================================================================
--- team/group/taskprocessors/apps/app_voicemail.c (original)
+++ team/group/taskprocessors/apps/app_voicemail.c Thu Mar 27 17:46:56 2008
@@ -8018,7 +8018,6 @@
 
 	ast_free(uniqueid);	
 	task->_datap = NULL;
-	ast_log(LOG_DEBUG, "unsubscribe handled\n");
 	return 0;
 }
 
@@ -8052,7 +8051,6 @@
 	AST_RWLIST_UNLOCK(&mwi_subs);
 	ast_free(p);	
 	task->_datap = NULL;
-	ast_log(LOG_DEBUG, "subscribe handled\n");
 	return 0;
 }
 

Modified: team/group/taskprocessors/include/asterisk/taskprocessor.h
URL: http://svn.digium.com/view/asterisk/team/group/taskprocessors/include/asterisk/taskprocessor.h?view=diff&rev=111532&r1=111531&r2=111532
==============================================================================
--- team/group/taskprocessors/include/asterisk/taskprocessor.h (original)
+++ team/group/taskprocessors/include/asterisk/taskprocessor.h Thu Mar 27 17:46:56 2008
@@ -1,7 +1,7 @@
 /*
  * Asterisk -- An open source telephony toolkit.
  *
- * Copyright (C) 2007, Dwayne M. Hubbard 
+ * Copyright (C) 2007-2008, Dwayne M. Hubbard 
  *
  * Dwayne M. Hubbard <dhubbard at digium.com>
  *
@@ -45,7 +45,6 @@
 struct taskprocessor_singleton_info {
 	char _name[80];
 	unsigned long _id;
-	int _is_purged;
 	ast_cond_t _poll_cond;
 	pthread_t _poll_thread;
 	ast_mutex_t _taskprocessor_lock;

Modified: team/group/taskprocessors/main/taskprocessor.c
URL: http://svn.digium.com/view/asterisk/team/group/taskprocessors/main/taskprocessor.c?view=diff&rev=111532&r1=111531&r2=111532
==============================================================================
--- team/group/taskprocessors/main/taskprocessor.c (original)
+++ team/group/taskprocessors/main/taskprocessor.c Thu Mar 27 17:46:56 2008
@@ -220,7 +220,6 @@
 	struct taskprocessor_singleton_info *i;
 	struct a_task *t;
 	int size;
-	int killflag = 0;
 
 	i = (struct taskprocessor_singleton_info*)data;
 	if (!i) {
@@ -228,7 +227,7 @@
 		return NULL;
 	}
 
-	while ((!killflag) && (i->_poll_thread_run)) {
+	while (i->_poll_thread_run) {
 		if ((size = ast_taskprocessor_depth(i)) > 0) {
 			/* stuff is in the queue */
 			t = ast_taskprocessor_pop(i);
@@ -253,11 +252,13 @@
 			ast_task_free(t);
 			if (--size) continue;
 		}
-		if (!killflag) {
-			ast_mutex_lock(&i->_taskprocessor_lock);
-			ast_cond_wait(&i->_poll_cond, &i->_taskprocessor_lock);
+		ast_mutex_lock(&i->_taskprocessor_lock);
+		if (!i->_poll_thread_run) {
 			ast_mutex_unlock(&i->_taskprocessor_lock);
-		}	
+			break;
+		}
+		ast_cond_wait(&i->_poll_cond, &i->_taskprocessor_lock);
+		ast_mutex_unlock(&i->_taskprocessor_lock);
 	}
 	while (ast_taskprocessor_depth(i)) {
 		/* stuff is in the queue */
@@ -267,7 +268,6 @@
 			t = NULL;
 		}
 	}
-	i->_is_purged = 1;
 	return NULL;
 }
 
@@ -328,7 +328,7 @@
 		if (!strcasecmp(p->_name, name)) {
 			AST_LIST_UNLOCK(&_taskprocessor_singletons);
 			ao2_ref(p, 1);
-			ast_log(LOG_DEBUG, "taskprocessor_singleton \'%s\' already exists!.\n", p->_name);
+			ast_debug(5, "taskprocessor_singleton \'%s\' already exists!.\n", p->_name);
 			return p;
 		}
 	}
@@ -344,14 +344,13 @@
 		ao2_ref(p, -1);
 		return NULL;
 	}
-	ast_log(LOG_DEBUG, "creating taskprocessor \'%s\', taskprocessor count: %d\n", name, ast_taskprocessor_count());
+	ast_debug(5, "creating taskprocessor \'%s\', taskprocessor count: %d\n", name, ast_taskprocessor_count());
 	/* stay stopped if we are supposed to be stopped */
 	if (p->_poll_thread == AST_PTHREADT_STOP) {
 		ao2_ref(p, -1);
 		return NULL;
 	}
 	if (p->_poll_thread == pthread_self()) {
-		ast_log(LOG_DEBUG, "cannot kill myself.\n");
 		ao2_ref(p, -1);
 		return NULL;
 	}
@@ -383,7 +382,7 @@
 	struct taskprocessor_singleton_info *n;
 	struct taskprocessor_singleton_info *t = (struct taskprocessor_singleton_info *)tps;
 
-	ast_log(LOG_DEBUG, "destroying taskprocessor \'%s\'\n", t->_name);
+	ast_debug(5, "destroying taskprocessor \'%s\'\n", t->_name);
 	if (!t) {
 		ast_log(LOG_ERROR, "can't destruct a NULL taskprocessor_singleton.\n");
 		return;
@@ -393,13 +392,13 @@
 		if (n == t) {
 			AST_LIST_REMOVE(&_taskprocessor_singletons, n, list);
 			_taskprocessor_singletons_list_size -= 1;
-			ast_log(LOG_DEBUG, "taskprocessor_singleton \'%s\' removed.\n", t->_name);
+			ast_debug(5, "taskprocessor_singleton \'%s\' removed.\n", t->_name);
 			break;
 		}
 	}
 	AST_LIST_UNLOCK(&_taskprocessor_singletons);
+	ast_mutex_lock(&t->_taskprocessor_lock);
 	t->_poll_thread_run = 0;
-	ast_mutex_lock(&t->_taskprocessor_lock);
 	ast_cond_signal(&t->_poll_cond);
 	ast_mutex_unlock(&t->_taskprocessor_lock);
 	pthread_join(t->_poll_thread, NULL);




More information about the asterisk-commits mailing list