Add new threadpool test and fix some taskprocessor bugs.

The new thread creation test fails because Asterisk locks up
while trying to lock a taskprocessor.

While trying to debug that, I found a race condition during taskprocessor
creation where a default taskprocessor listener could try to operate on
a partially started taskprocessor. This was fixed by adding a new callback
to taskprocessor listeners.

Then while testing that change, I found some bugs in the taskprocessor
tests where I was not properly unlocking when done with a lock. Scoped
locks have spoiled me a bit.

I still have not figured out why the threadpool thread creation test
is locking up.



git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377368 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Michelson
2012-12-07 00:30:35 +00:00
parent 62981d2032
commit 4590bfd93d
5 changed files with 106 additions and 3 deletions

View File

@@ -268,6 +268,11 @@ static void *threadpool_alloc(struct ast_taskprocessor_listener *listener)
return pool;
}
static int threadpool_tps_start(struct ast_taskprocessor_listener *listener)
{
return 0;
}
/*!
* \brief helper used for queued task when tasks are pushed
*/
@@ -431,6 +436,7 @@ static void threadpool_destroy(void *private_data)
*/
static struct ast_taskprocessor_listener_callbacks threadpool_tps_listener_callbacks = {
.alloc = threadpool_alloc,
.start = threadpool_tps_start,
.task_pushed = threadpool_tps_task_pushed,
.emptied = threadpool_tps_emptied,
.shutdown = threadpool_tps_shutdown,
@@ -623,6 +629,7 @@ struct ast_threadpool *ast_threadpool_create(struct ast_threadpool_listener *lis
pool = tps_listener->private_data;
pool->tps = tps;
ast_log(LOG_NOTICE, "The taskprocessor I've created is located at %p\n", pool->tps);
ao2_ref(listener, +1);
pool->listener = listener;
ast_threadpool_set_size(pool, initial_size);