]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
channel.c: Make CHECK_BLOCKING() save thread LWP id for messages.
authorRichard Mudgett <rmudgett@digium.com>
Wed, 13 Jun 2018 16:33:44 +0000 (11:33 -0500)
committerRichard Mudgett <rmudgett@digium.com>
Tue, 19 Jun 2018 19:13:07 +0000 (14:13 -0500)
* Removed an unnecessary call to ast_channel_blocker_set() in
__ast_read().

ASTERISK-27625

Change-Id: I342168b999984666fb869cd519fe779583a73834

include/asterisk/channel.h
main/channel.c
main/channel_internal_api.c

index 8c171b6f1b8e4feb03501b4f4f412f1234c4b370..d7091593b497b1dc36cbb06ddc8997397c0ff42e 100644 (file)
@@ -2664,11 +2664,12 @@ static inline enum ast_t38_state ast_channel_get_t38_state(struct ast_channel *c
        do { \
                if (ast_test_flag(ast_channel_flags(c), AST_FLAG_BLOCKING)) { \
                        /* This should not happen as there should only be one thread handling a channel's media at a time. */ \
-                       ast_log(LOG_DEBUG, "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_log(LOG_DEBUG, "Thread LWP %d is blocking '%s', already blocked by thread LWP %d in procedure %s\n", \
+                               ast_get_tid(), ast_channel_name(c), \
+                               ast_channel_blocker_tid(c), ast_channel_blockproc(c)); \
                        ast_assert(0); \
                } \
+               ast_channel_blocker_tid_set((c), ast_get_tid()); \
                ast_channel_blocker_set((c), pthread_self()); \
                ast_channel_blockproc_set((c), __PRETTY_FUNCTION__); \
                ast_set_flag(ast_channel_flags(c), AST_FLAG_BLOCKING); \
@@ -4316,6 +4317,9 @@ void ast_channel_internal_epfd_data_set(struct ast_channel *chan, int which , st
 pthread_t ast_channel_blocker(const struct ast_channel *chan);
 void ast_channel_blocker_set(struct ast_channel *chan, pthread_t value);
 
+int ast_channel_blocker_tid(const struct ast_channel *chan);
+void ast_channel_blocker_tid_set(struct ast_channel *chan, int tid);
+
 ast_timing_func_t ast_channel_timingfunc(const struct ast_channel *chan);
 void ast_channel_timingfunc_set(struct ast_channel *chan, ast_timing_func_t value);
 
index 2a72aeed21b69368310e47ae2bbb2ad7950d946d..753bb1a00c96ee6cd0c60e528eab0b72017708b8 100644 (file)
@@ -2735,10 +2735,10 @@ void ast_hangup(struct ast_channel *chan)
        ast_channel_generator_set(chan, NULL);
 
        if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_BLOCKING)) {
-               ast_log(LOG_WARNING, "Hard hangup called by thread %ld on %s, while fd "
-                       "is blocked by thread %ld in procedure %s!  Expect a failure\n",
-                       (long) pthread_self(), ast_channel_name(chan), (long)ast_channel_blocker(chan), ast_channel_blockproc(chan));
-               ast_assert(ast_test_flag(ast_channel_flags(chan), AST_FLAG_BLOCKING) == 0);
+               ast_log(LOG_WARNING, "Hard hangup called by thread LWP %d on %s, while blocked by thread LWP %d in procedure %s!  Expect a failure\n",
+                       ast_get_tid(), ast_channel_name(chan), ast_channel_blocker_tid(chan),
+                       ast_channel_blockproc(chan));
+               ast_assert(0);
        }
 
        if (ast_channel_tech(chan)->hangup) {
@@ -3964,7 +3964,6 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
                        }
                }
        } else {
-               ast_channel_blocker_set(chan, pthread_self());
                if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_EXCEPTION)) {
                        if (ast_channel_tech(chan)->exception)
                                f = ast_channel_tech(chan)->exception(chan);
index d181f52a2b81a2e625e4e6c49f6f19a7a514e38b..6e429b3db1151fe9715c3f035add752ca963ebf1 100644 (file)
@@ -169,6 +169,7 @@ struct ast_channel {
        unsigned long insmpl;                           /*!< Track the read/written samples for monitor use */
        unsigned long outsmpl;                          /*!< Track the read/written samples for monitor use */
 
+       int blocker_tid;                                        /*!< If anyone is blocking, this is their thread id */
        int fds[AST_MAX_FDS];                           /*!< File descriptors for channel -- Drivers will poll on
                                                         *   these file descriptors, so at least one must be non -1.
                                                         *   See \arg \ref AstFileDesc */
@@ -1331,6 +1332,15 @@ void ast_channel_blocker_set(struct ast_channel *chan, pthread_t value)
        chan->blocker = value;
 }
 
+int ast_channel_blocker_tid(const struct ast_channel *chan)
+{
+       return chan->blocker_tid;
+}
+void ast_channel_blocker_tid_set(struct ast_channel *chan, int value)
+{
+       chan->blocker_tid = value;
+}
+
 ast_timing_func_t ast_channel_timingfunc(const struct ast_channel *chan)
 {
        return chan->timingfunc;