[asterisk-commits] dlee: branch dlee/stasis-core r381829 - in /team/dlee/stasis-core: main/ tests/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Feb 20 11:48:12 CST 2013


Author: dlee
Date: Wed Feb 20 11:48:09 2013
New Revision: 381829

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=381829
Log:
Clean up destruction order bug

Modified:
    team/dlee/stasis-core/main/stasis.c
    team/dlee/stasis-core/tests/test_stasis.c

Modified: team/dlee/stasis-core/main/stasis.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-core/main/stasis.c?view=diff&rev=381829&r1=381828&r2=381829
==============================================================================
--- team/dlee/stasis-core/main/stasis.c (original)
+++ team/dlee/stasis-core/main/stasis.c Wed Feb 20 11:48:09 2013
@@ -169,12 +169,12 @@
 
 void stasis_unsubscribe(struct stasis_subscription *sub)
 {
-	size_t i;
-
 	if (sub) {
+		RAII_VAR(struct stasis_subscription *, cleanup_after_unlock, NULL, ao2_cleanup);
 		SCOPED_AO2LOCK(lock, sub);
 
 		if (sub->topic) {
+			size_t i;
 			struct stasis_topic *topic = sub->topic;
 			SCOPED_AO2LOCK(lock, topic);
 
@@ -183,7 +183,8 @@
 					sub->topic = NULL;
 					/* swap [i] with last entry; remove last entry */
 					topic->subscribers[i] = topic->subscribers[--topic->num_subscribers_current];
-					ao2_cleanup(sub);
+					/* We can't clean up now, since the lock is held. defer to RAII */
+					cleanup_after_unlock = sub;
 					return;
 				}
 			}

Modified: team/dlee/stasis-core/tests/test_stasis.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-core/tests/test_stasis.c?view=diff&rev=381829&r1=381828&r2=381829
==============================================================================
--- team/dlee/stasis-core/tests/test_stasis.c (original)
+++ team/dlee/stasis-core/tests/test_stasis.c Wed Feb 20 11:48:09 2013
@@ -406,9 +406,9 @@
 	RAII_VAR(struct stasis_message_type *, non_cache_type, NULL, ao2_cleanup);
 	RAII_VAR(struct stasis_topic *, topic, NULL, ao2_cleanup);
 	RAII_VAR(struct stasis_caching_topic *, caching_topic, NULL, ao2_cleanup);
+	RAII_VAR(struct consumer *, consumer, NULL, ao2_cleanup);
 	RAII_VAR(struct stasis_subscription *, sub, NULL, ao2_cleanup);
 	RAII_VAR(struct stasis_message *, test_message, NULL, ao2_cleanup);
-	RAII_VAR(struct consumer *, consumer, NULL, ao2_cleanup);
 	int actual_len;
 	struct stasis_message_type *actual_type;
 




More information about the asterisk-commits mailing list