[asterisk-commits] kmoore: branch kmoore/stasis-mwi r383103 - /team/kmoore/stasis-mwi/main/app.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Mar 14 14:04:17 CDT 2013


Author: kmoore
Date: Thu Mar 14 14:04:14 2013
New Revision: 383103

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=383103
Log:
Lock the topics container properly to prevent creation of duplicates

Modified:
    team/kmoore/stasis-mwi/main/app.c

Modified: team/kmoore/stasis-mwi/main/app.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-mwi/main/app.c?view=diff&rev=383103&r1=383102&r2=383103
==============================================================================
--- team/kmoore/stasis-mwi/main/app.c (original)
+++ team/kmoore/stasis-mwi/main/app.c Thu Mar 14 14:04:14 2013
@@ -2689,7 +2689,9 @@
 
 struct stasis_topic *stasis_mwi_topic(const char *uniqueid)
 {
-	RAII_VAR(struct mwi_topic *, mwi_topic, ao2_find(mwi_topics, uniqueid, OBJ_KEY), ao2_cleanup);
+	RAII_VAR(struct mwi_topic *, mwi_topic, NULL, ao2_cleanup);
+	SCOPED_AO2LOCK(topic_container_lock, mwi_topics);
+	mwi_topic = ao2_find(mwi_topics, uniqueid, OBJ_KEY | OBJ_NOLOCK);
 
 	if (mwi_topic) {
 		return mwi_topic->topic;
@@ -2716,7 +2718,7 @@
 		return NULL;
 	}
 
-	ao2_link(mwi_topics, mwi_topic);
+	ao2_link_flags(mwi_topics, mwi_topic, OBJ_NOLOCK);
 
 	return mwi_topic->topic;
 }




More information about the asterisk-commits mailing list