]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Astobj2: Run weakproxy subscription callbacks in reverse order. 25/525/2
authorCorey Farrell <git@cfware.com>
Fri, 22 May 2015 21:52:29 +0000 (17:52 -0400)
committerCorey Farrell <git@cfware.com>
Fri, 22 May 2015 22:09:47 +0000 (17:09 -0500)
Modify ao2_weakproxy_subscribe so each new subscription is added
to the head of the list.  This ensures that when other objects
are allocated and use a subscription to the weakproxy for cleanup,
cleanup will occur in the correct order.

ASTERISK-25120 #close

Change-Id: Ie0476f08ec21330de1b3f5a2dd3d9eb683df3d3d

include/asterisk/astobj2.h
main/astobj2.c

index e02a4cd85404dbeb8ee7b6a0d5ef65f8801abd84..4a7aeeedd2a73fe5be2002b58cddb315049780be 100644 (file)
@@ -612,6 +612,8 @@ void *__ao2_weakproxy_get_object(void *weakproxy, int flags,
  * \retval 0 Success
  * \retval -1 Failure
  *
+ * \note Callbacks are run in the reverse order of subscriptions.
+ *
  * \note This procedure will allow the same cb / data pair to be added to
  *       the same weakproxy multiple times.
  *
index 1db2dd42dcf44b3d00a994182f1deae786b256a1..ed91577be40fae03082397084269ecaa09f11fef 100644 (file)
@@ -928,7 +928,7 @@ int ao2_weakproxy_subscribe(void *weakproxy, ao2_weakproxy_notification_cb cb, v
                if (sub) {
                        sub->cb = cb;
                        sub->data = data;
-                       AST_LIST_INSERT_TAIL(&weak->destroyed_cb, sub, list);
+                       AST_LIST_INSERT_HEAD(&weak->destroyed_cb, sub, list);
                        ret = 0;
                }
        } else {