[Asterisk-code-review] channel: Add assertion to CHECK BLOCKING. (asterisk[13])
Corey Farrell
asteriskteam at digium.com
Sat Jan 27 14:34:16 CST 2018
Corey Farrell has uploaded this change for review. ( https://gerrit.asterisk.org/8075
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, 16 insertions(+), 9 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/75/8075/1
diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h
index 393c020..fbf253e 100644
--- a/include/asterisk/channel.h
+++ b/include/asterisk/channel.h
@@ -2599,15 +2599,22 @@
return state;
}
-#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)
+#define CHECK_BLOCKING(c) \
+ ({ \
+ 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); \
+ })
ast_group_t ast_get_group(const char *s);
--
To view, visit https://gerrit.asterisk.org/8075
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia6cacc9c862f2653d1b650511725e53e48e8e653
Gerrit-Change-Number: 8075
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/55f2ffcd/attachment.html>
More information about the asterisk-code-review
mailing list