From: ktyerman Date: Tue, 5 Jun 2018 01:31:39 +0000 (+1000) Subject: chan_iax2: better handling for timeout and EINTR X-Git-Tag: 13.22.0-rc1~29 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c6116a323400229590181106fe93d7c3cb69be47;p=thirdparty%2Fasterisk.git chan_iax2: better handling for timeout and EINTR 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 --- diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index e51561a088..4e3816e72a 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -12583,6 +12583,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); } @@ -12592,7 +12594,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; } }