[Asterisk-code-review] channel: Add assertion to CHECK BLOCKING. (asterisk[master])

Corey Farrell asteriskteam at digium.com
Sat Jan 27 13:53:36 CST 2018


Corey Farrell has uploaded this change for review. ( https://gerrit.asterisk.org/8073


Change subject: channel: Add assertion to CHECK_BLOCKING.
......................................................................

channel: Add assertion to CHECK_BLOCKING.

Throw an assertion if CHECK_BLOCKING is called when blocking is already
enabled.  The macro also returns -1 or 0 based on success but nothing
checks the value yet.  I'd like to see if the assertions cause issues
for the testsuite before going further or produces FRACK logger
backtraces in production before moving making additional changes.

ASTERISK-27625

Change-Id: Ia6cacc9c862f2653d1b650511725e53e48e8e653
---
M include/asterisk/channel.h
1 file changed, 14 insertions(+), 8 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/73/8073/1

diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h
index 3dfbe61..8813813 100644
--- a/include/asterisk/channel.h
+++ b/include/asterisk/channel.h
@@ -2709,14 +2709,20 @@
 }
 
 #define CHECK_BLOCKING(c) do { 	 \
-	if (ast_test_flag(ast_channel_flags(c), AST_FLAG_BLOCKING)) {\
-		ast_debug(1, "Thread %p is blocking '%s', already blocked by thread %p in procedure %s\n", \
-			(void *) pthread_self(), ast_channel_name(c), (void *) ast_channel_blocker(c), ast_channel_blockproc(c)); \
-	} else { \
-		ast_channel_blocker_set((c), pthread_self()); \
-		ast_channel_blockproc_set((c), __PRETTY_FUNCTION__); \
-		ast_set_flag(ast_channel_flags(c), AST_FLAG_BLOCKING); \
-	} } while (0)
+		int __ret = 0; \
+		if (ast_test_flag(ast_channel_flags(c), AST_FLAG_BLOCKING)) {\
+			ast_log(LOG_ERROR, "Thread %p is blocking '%s', already blocked by thread %p in procedure %s\n", \
+				(void *) pthread_self(), ast_channel_name(c), (void *) ast_channel_blocker(c), ast_channel_blockproc(c)); \
+			__ast_assert_failed(0, "The channel is already blocked by another thread.", \
+				__FILE__, __LINE__, __PRETTY_FUNCTION__); \
+			__ret = -1; \
+		} else { \
+			ast_channel_blocker_set((c), pthread_self()); \
+			ast_channel_blockproc_set((c), __PRETTY_FUNCTION__); \
+			ast_set_flag(ast_channel_flags(c), AST_FLAG_BLOCKING); \
+		} \
+		(__ret); \
+	} while (0)
 
 ast_group_t ast_get_group(const char *s);
 

-- 
To view, visit https://gerrit.asterisk.org/8073
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia6cacc9c862f2653d1b650511725e53e48e8e653
Gerrit-Change-Number: 8073
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180127/30c8a7a9/attachment-0001.html>


More information about the asterisk-code-review mailing list