diff options
author | Mark Michelson <mmichelson@digium.com> | 2012-12-07 00:30:35 +0000 |
---|---|---|
committer | Mark Michelson <mmichelson@digium.com> | 2012-12-07 00:30:35 +0000 |
commit | 4590bfd93d7124fbd042f17260738e315e0abb6e (patch) | |
tree | 1579fa64689d9d5da754444e4ba41a9bc6c3f4a4 /main/threadpool.c | |
parent | 62981d203221541829b7d6165e2127ca9a29efd4 (diff) |
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
Diffstat (limited to 'main/threadpool.c')
-rw-r--r-- | main/threadpool.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/main/threadpool.c b/main/threadpool.c index 1da0d0766..1b0477926 100644 --- a/main/threadpool.c +++ b/main/threadpool.c @@ -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); |