Fix infinite looping and crash problem.
authorMark Michelson <mmichelson@digium.com>
Fri, 7 Dec 2012 19:05:30 +0000 (19:05 +0000)
committerMark Michelson <mmichelson@digium.com>
Fri, 7 Dec 2012 19:05:30 +0000 (19:05 +0000)
MALLOC_DEBUG is complaining about corrupted memory on taskprocessor
listeners, but I'm not seeing it, nor is valgrind. Not sure what's up
there.

git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377377 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/taskprocessor.c
main/threadpool.c

index 80875ec..1a768de 100644 (file)
@@ -581,8 +581,6 @@ struct ast_taskprocessor *ast_taskprocessor_create_with_listener(const char *nam
 /* decrement the taskprocessor reference count and unlink from the container if necessary */
 void *ast_taskprocessor_unreference(struct ast_taskprocessor *tps)
 {
-       struct ast_taskprocessor_listener *listener;
-
        if (!tps) {
                return NULL;
        }
@@ -596,10 +594,7 @@ void *ast_taskprocessor_unreference(struct ast_taskprocessor *tps)
         * 3. The listener
         */
        ao2_unlink(tps_singletons, tps);
-       listener = tps->listener;
-       tps->listener = NULL;
-       listener_shutdown(listener);
-       ao2_ref(listener, -1);
+       listener_shutdown(tps->listener);
        return NULL;
 }
 
index 1b04779..5ed9a42 100644 (file)
@@ -784,7 +784,7 @@ static void worker_active(struct worker_thread *worker)
 {
        int alive = 1;
        while (alive) {
-               if (threadpool_execute(worker->pool)) {
+               if (threadpool_execute(worker->pool) == 0) {
                        alive = worker_idle(worker);
                }
        }