[svn-commits] rmudgett: trunk r411702 - in /trunk: ./ main/ res/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Apr 4 12:57:50 CDT 2014


Author: rmudgett
Date: Fri Apr  4 12:57:46 2014
New Revision: 411702

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=411702
Log:
locking: Add temporary sanity checks.

Add some temporary sanity checks to hunt for locking problems with the
masquerade supertest.

Modified:
    trunk/   (props changed)
    trunk/main/channel.c
    trunk/main/stasis_cache.c
    trunk/main/utils.c
    trunk/res/res_musiconhold.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-12-merged' - no diff available.

Modified: trunk/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/channel.c?view=diff&rev=411702&r1=411701&r2=411702
==============================================================================
--- trunk/main/channel.c (original)
+++ trunk/main/channel.c Fri Apr  4 12:57:46 2014
@@ -884,9 +884,8 @@
 	ast_channel_stage_snapshot(tmp);
 
 	if (!(nativeformats = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_CACHE_STRINGS))) {
-		ao2_ref(tmp, -1);
 		/* format capabilities structure allocation failure */
-		return NULL;
+		return ast_channel_unref(tmp);
 	}
 	ast_channel_nativeformats_set(tmp, nativeformats);
 
@@ -2263,10 +2262,16 @@
 
 	/* Things that may possibly raise Stasis messages shouldn't occur after this point */
 	ast_set_flag(ast_channel_flags(chan), AST_FLAG_DEAD);
-	ast_channel_lock(chan);
-	ast_channel_publish_snapshot(chan);
-	ast_channel_unlock(chan);
-	publish_cache_clear(chan);
+
+	if (ast_channel_internal_is_finalized(chan)) {
+		/* A channel snapshot should not be in the process of being staged now. */
+		ast_assert(!ast_test_flag(ast_channel_flags(chan), AST_FLAG_SNAPSHOT_STAGE));
+
+		ast_channel_lock(chan);
+		ast_channel_publish_snapshot(chan);
+		ast_channel_unlock(chan);
+		publish_cache_clear(chan);
+	}
 
 	ast_channel_lock(chan);
 

Modified: trunk/main/stasis_cache.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/stasis_cache.c?view=diff&rev=411702&r1=411701&r2=411702
==============================================================================
--- trunk/main/stasis_cache.c (original)
+++ trunk/main/stasis_cache.c Fri Apr  4 12:57:46 2014
@@ -343,10 +343,17 @@
 static struct stasis_cache_entry *cache_find(struct ao2_container *entries, struct stasis_message_type *type, const char *id)
 {
 	struct cache_entry_key search_key;
+	struct stasis_cache_entry *entry;
 
 	search_key.type = type;
 	search_key.id = id;
-	return ao2_find(entries, &search_key, OBJ_SEARCH_KEY | OBJ_NOLOCK);
+	entry = ao2_find(entries, &search_key, OBJ_SEARCH_KEY | OBJ_NOLOCK);
+
+	/* Ensure that what we looked for is what we found. */
+	ast_assert(!entry
+		|| (!strcmp(stasis_message_type_name(entry->key.type),
+			stasis_message_type_name(type)) && !strcmp(entry->key.id, id)));
+	return entry;
 }
 
 /*!

Modified: trunk/main/utils.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/utils.c?view=diff&rev=411702&r1=411701&r2=411702
==============================================================================
--- trunk/main/utils.c (original)
+++ trunk/main/utils.c Fri Apr  4 12:57:46 2014
@@ -52,6 +52,7 @@
 #include "asterisk/sha1.h"
 #include "asterisk/cli.h"
 #include "asterisk/linkedlists.h"
+#include "asterisk/astobj2.h"
 
 #define AST_API_MODULE		/* ensure that inlinable API functions will be built in this module if required */
 #include "asterisk/strings.h"
@@ -2523,6 +2524,10 @@
 		condition_str, condition);
 	fprintf(stderr, "FRACK!, Failed assertion %s (%d) at line %d in %s of %s\n",
 		condition_str, condition, line, function, file);
+
+	/* Generate a backtrace for the assert */
+	ao2_bt();
+
 	/*
 	 * Give the logger a chance to get the message out, just in case
 	 * we abort(), or Asterisk crashes due to whatever problem just

Modified: trunk/res/res_musiconhold.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_musiconhold.c?view=diff&rev=411702&r1=411701&r2=411702
==============================================================================
--- trunk/res/res_musiconhold.c (original)
+++ trunk/res/res_musiconhold.c Fri Apr  4 12:57:46 2014
@@ -280,6 +280,9 @@
 	message = ast_channel_blob_create_from_cache(ast_channel_uniqueid(chan),
 		ast_channel_moh_start_type(), json_object);
 	if (message) {
+		/* A channel snapshot must have been in the cache. */
+		ast_assert(((struct ast_channel_blob *) stasis_message_data(message))->snapshot != NULL);
+
 		stasis_publish(ast_channel_topic(chan), message);
 	}
 	ao2_cleanup(message);
@@ -295,6 +298,9 @@
 	message = ast_channel_blob_create_from_cache(ast_channel_uniqueid(chan),
 		ast_channel_moh_stop_type(), NULL);
 	if (message) {
+		/* A channel snapshot must have been in the cache. */
+		ast_assert(((struct ast_channel_blob *) stasis_message_data(message))->snapshot != NULL);
+
 		stasis_publish(ast_channel_topic(chan), message);
 	}
 	ao2_cleanup(message);




More information about the svn-commits mailing list