[Asterisk-code-review] chan iax2: better handling for timeout and EINTR (asterisk[13])

Kirsty Tyerman asteriskteam at digium.com
Wed Jun 13 17:46:41 CDT 2018


Kirsty Tyerman has uploaded this change for review. ( https://gerrit.asterisk.org/9187


Change subject: chan_iax2: better handling for timeout and EINTR
......................................................................

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
---
M channels/chan_iax2.c
1 file changed, 7 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/87/9187/1

diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index e51561a..4e3816e 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -12583,6 +12583,8 @@
 
 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 @@
 		/* 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;
 		}
 	}

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

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib4c32562f69335869adc1783608e940c3535fbfb
Gerrit-Change-Number: 9187
Gerrit-PatchSet: 1
Gerrit-Owner: Kirsty Tyerman <kirsty.tyerman at boeing.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180613/3381d4e3/attachment-0001.html>


More information about the asterisk-code-review mailing list