[asterisk-commits] kmoore: branch kmoore/stasis-device_state r383102 - /team/kmoore/stasis-devic...

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


Author: kmoore
Date: Thu Mar 14 14:03:24 2013
New Revision: 383102

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=383102
Log:
Lock the topics container properly so duplicate topics are not created

Modified:
    team/kmoore/stasis-device_state/main/devicestate.c

Modified: team/kmoore/stasis-device_state/main/devicestate.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-device_state/main/devicestate.c?view=diff&rev=383102&r1=383101&r2=383102
==============================================================================
--- team/kmoore/stasis-device_state/main/devicestate.c (original)
+++ team/kmoore/stasis-device_state/main/devicestate.c Thu Mar 14 14:03:24 2013
@@ -744,7 +744,9 @@
 
 struct stasis_topic *stasis_device_state_topic(const char *device)
 {
-	RAII_VAR(struct device_state_topic *, device_state_topic, ao2_find(device_state_topics, device, OBJ_KEY), ao2_cleanup);
+	RAII_VAR(struct device_state_topic *, device_state_topic, NULL, ao2_cleanup);
+	SCOPED_AO2LOCK(topic_container_lock, device_state_topics);
+	device_state_topic = ao2_find(device_state_topics, device, OBJ_KEY | OBJ_NOLOCK);
 
 	if (device_state_topic) {
 		return device_state_topic->topic;
@@ -771,7 +773,7 @@
 		return NULL;
 	}
 
-	ao2_link(device_state_topics, device_state_topic);
+	ao2_link_flags(device_state_topics, device_state_topic, OBJ_NOLOCK);
 
 	return device_state_topic->topic;
 }




More information about the asterisk-commits mailing list