]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
chan_iax2: better handling for timeout and EINTR
authorktyerman <kirsty.tyerman@boeing.com>
Tue, 5 Jun 2018 01:31:39 +0000 (11:31 +1000)
committerRichard Mudgett <rmudgett@digium.com>
Wed, 13 Jun 2018 12:09:22 +0000 (06:09 -0600)
The iax2 module is not handling timeout and EINTR case properly. Mainly when
there is an interupt to the kernel thread. In case of ast_io_wait recieves a
signal, or timeout it can be an error or return 0 which eventually escapes the
thread loop, so that it cant recieve any data. This then causes the modules
receive queue to build up on the kernel and stop any communications via iax in
asterisk.

The proposed patch is for the iax module, so that timeout and EINTR does not
exit the thread.

ASTERISK-27705
Reported-by: Kirsty Tyerman
Change-Id: Ib4c32562f69335869adc1783608e940c3535fbfb

channels/chan_iax2.c

index 28282dccd53790c36ca9654c1d4493149891aab0..66d1330f7a3c4347b5421f866fb5ec09b60bfb72 100644 (file)
@@ -12551,6 +12551,8 @@ static struct ast_channel *iax2_request(const char *type, struct ast_format_cap
 
 static void *network_thread(void *ignore)
 {
+       int res;
+
        if (timer) {
                ast_io_add(io, ast_timer_fd(timer), timing_read, AST_IO_IN | AST_IO_PRI, NULL);
        }
@@ -12560,7 +12562,11 @@ static void *network_thread(void *ignore)
                /* Wake up once a second just in case SIGURG was sent while
                 * we weren't in poll(), to make sure we don't hang when trying
                 * to unload. */
-               if (ast_io_wait(io, 1000) <= 0) {
+               res = ast_io_wait(io, 1000);
+               /* Timeout(=0), and EINTR is not a thread exit condition. We do
+                * not want to exit the thread loop on these conditions. */
+               if (res < 0 && errno != -EINTR) {
+                       ast_log(LOG_ERROR, "IAX2 network thread unexpected exit: %s\n", strerror(errno));
                        break;
                }
        }