[Asterisk-code-review] chan iax2: better handling for timeout and EINTR (asterisk[master])
Joshua Colp
asteriskteam at digium.com
Thu Jun 14 10:25:40 CDT 2018
Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/9188 )
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(-)
Approvals:
Richard Mudgett: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved
Joshua Colp: Approved for Submit
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 6420b5d..01d42b5 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -12552,6 +12552,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);
}
@@ -12561,7 +12563,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/9188
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib4c32562f69335869adc1783608e940c3535fbfb
Gerrit-Change-Number: 9188
Gerrit-PatchSet: 1
Gerrit-Owner: Kirsty Tyerman <kirsty.tyerman at boeing.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180614/f596462d/attachment.html>
More information about the asterisk-code-review
mailing list