[asterisk-commits] kmoore: branch kmoore/stasis-mwi r382484 - /team/kmoore/stasis-mwi/main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Mar 6 08:00:49 CST 2013


Author: kmoore
Date: Wed Mar  6 08:00:46 2013
New Revision: 382484

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=382484
Log:
Prevent an extra unref in the stasis caching layer

cache_put was mistakenly leaving a reference to a snapshot in a cache
entry to be destroyed where the rest of the code was shuffling refs
around properly. This fixes the extra deref and prevents premature
destruction.

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

Modified: team/kmoore/stasis-mwi/main/stasis_cache.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-mwi/main/stasis_cache.c?view=diff&rev=382484&r1=382483&r2=382484
==============================================================================
--- team/kmoore/stasis-mwi/main/stasis_cache.c (original)
+++ team/kmoore/stasis-mwi/main/stasis_cache.c Wed Mar  6 08:00:46 2013
@@ -150,7 +150,7 @@
 {
 	RAII_VAR(struct cache_entry *, new_entry, NULL, ao2_cleanup);
 	RAII_VAR(struct cache_entry *, cached_entry, NULL, ao2_cleanup);
-	RAII_VAR(struct stasis_message *, old_snapshot, NULL, ao2_cleanup);
+	struct stasis_message *old_snapshot = NULL;
 
 	ast_assert(caching_topic->cache != NULL);
 
@@ -159,7 +159,10 @@
 	if (new_snapshot == NULL) {
 		/* Remove entry from cache */
 		cached_entry = ao2_find(caching_topic->cache, new_entry, OBJ_POINTER | OBJ_UNLINK);
-		old_snapshot = cached_entry->snapshot;
+		if (cached_entry) {
+			old_snapshot = cached_entry->snapshot;
+			cached_entry->snapshot = NULL;
+		}
 	} else {
 		/* Insert/update cache */
 		SCOPED_AO2LOCK(lock, caching_topic->cache);
@@ -177,11 +180,6 @@
 
 	}
 
-	if (!old_snapshot) {
-		return NULL;
-	}
-
-	ao2_ref(old_snapshot, +1);
 	return old_snapshot;
 }
 




More information about the asterisk-commits mailing list