[asterisk-commits] dhubbard: branch group/taskprocessors r111564 - /team/group/taskprocessors/main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Mar 27 19:52:29 CDT 2008


Author: dhubbard
Date: Thu Mar 27 19:52:29 2008
New Revision: 111564

URL: http://svn.digium.com/view/asterisk?view=rev&rev=111564
Log:
add a safety comment and move the poll_thread_run flag

Modified:
    team/group/taskprocessors/main/taskprocessor.c

Modified: team/group/taskprocessors/main/taskprocessor.c
URL: http://svn.digium.com/view/asterisk/team/group/taskprocessors/main/taskprocessor.c?view=diff&rev=111564&r1=111563&r2=111564
==============================================================================
--- team/group/taskprocessors/main/taskprocessor.c (original)
+++ team/group/taskprocessors/main/taskprocessor.c Thu Mar 27 19:52:29 2008
@@ -329,6 +329,15 @@
 			AST_LIST_UNLOCK(&_taskprocessor_singletons);
 			ao2_ref(p, 1);
 			ast_debug(5, "taskprocessor_singleton \'%s\' already exists!.\n", p->_name);
+			/* a scenario here slightly worries me.  If a module calls ast_taskprocessor_reference(blah, 0) and then
+ 			 * another module calls ast_taskprocessor_reference(blah, custom_func) then the custom_func is not going
+ 			 * to be assigned to the taskprocessor because that name already exists with a different processing
+ 			 * function.  We might want to check for that and return a NULL if someone requests a taskprocessor that
+ 			 * already exists, but the processing function doesn't match.  In any case, this stuff is not happening
+ 			 * dynamically and one would think that this scenario would be caught before a commit was made, but I'm
+ 			 * pretty sure that stranger things have happened.
+ 			 *
+ 			 * In the meantime, if the processor thread already exists, return it without comparing processing functions. */
 			return p;
 		}
 	}
@@ -338,12 +347,12 @@
 		return NULL;
 	}
 	snprintf(p->_name, sizeof(p->_name), "%s", name);
-	p->_poll_thread_run = 1;
 	if (tps_taskprocessor_add(p) < 0) {
 		ast_log(LOG_ERROR, "can't add taskprocessor_singleton \'%s\' with ID: 0x%X\n", p->_name, (unsigned int)p->_id);
 		ao2_ref(p, -1);
 		return NULL;
 	}
+	p->_poll_thread_run = 1;
 	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) {




More information about the asterisk-commits mailing list