Fix lock destruction/unlock inversion
authorKinsey Moore <kmoore@digium.com>
Tue, 19 Mar 2013 19:07:46 +0000 (19:07 +0000)
committerKinsey Moore <kmoore@digium.com>
Tue, 19 Mar 2013 19:07:46 +0000 (19:07 +0000)
When using scoped locks, the unref of an AO2 object should happen after
the unlock occurs which requires usage of scoped refs.

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

main/stasis_message_router.c

index 01ad88a..97ed7ad 100644 (file)
@@ -91,6 +91,7 @@ static void router_dispatch(void *data,
                            struct stasis_message *message)
 {
        struct stasis_message_router *router = data;
+       RAII_VAR(struct stasis_message_router *, router_needs_cleanup, NULL, ao2_cleanup);
        RAII_VAR(struct stasis_message_route *, route, NULL, ao2_cleanup);
        struct stasis_message_type *type = stasis_message_type(message);
        size_t i;
@@ -123,7 +124,7 @@ static void router_dispatch(void *data,
        }
 
        if (stasis_subscription_final_message(sub, message)) {
-               ao2_cleanup(router);
+               router_needs_cleanup = router;
                return;
        }