]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Prevent crash on shutdown due to refcount error on queues container.
authorMark Michelson <mmichelson@digium.com>
Thu, 30 Aug 2012 20:51:51 +0000 (20:51 +0000)
committerMark Michelson <mmichelson@digium.com>
Thu, 30 Aug 2012 20:51:51 +0000 (20:51 +0000)
When app_queue is unloaded, the queues container has its refcount
decremented, potentially to 0. Then the taskprocessor responsible
for handling device state changes is unreferenced. If the
taskprocessor happens to be just about to run its task, then it
will create and destroy an iterator on the queues container.
This can cause the refcount on the queues container to increase to
1 and then back to 0. Going back to 0 a second time results in
double frees.

This failure was seen periodically in the testsuite when Asterisk
would shut down.

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@372089 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_queue.c

index 5b0da5cbf4b7e1bd1dad0b8cd5a7f06d1d12b46c..95833db20434a53b84f2cc4ff517950121fd2233 100644 (file)
@@ -8404,8 +8404,8 @@ static int unload_module(void)
                queue_t_unref(q, "Done with iterator");
        }
        ao2_iterator_destroy(&q_iter);
-       ao2_ref(queues, -1);
        devicestate_tps = ast_taskprocessor_unreference(devicestate_tps);
+       ao2_ref(queues, -1);
        ast_unload_realtime("queue_members");
        return res;
 }