From c28705fe7692399f6d9aa144feec8001f29e128d Mon Sep 17 00:00:00 2001 From: Aron Podrigal Date: Wed, 5 Jun 2024 16:20:18 -0500 Subject: [PATCH 1/3] mod_timerfd: Fixed - continue timer loop after receiving a SIGSTOP When taking a snapshot of a machine which pauses the process, mod_timerfd exits and freeswitch, causing all channels to wait indefinitely. Check `errno == EINTR` and continue the timer loop. --- src/mod/timers/mod_timerfd/mod_timerfd.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/mod/timers/mod_timerfd/mod_timerfd.c b/src/mod/timers/mod_timerfd/mod_timerfd.c index bd07be8cdda..dfd946d6b89 100644 --- a/src/mod/timers/mod_timerfd/mod_timerfd.c +++ b/src/mod/timers/mod_timerfd/mod_timerfd.c @@ -30,6 +30,7 @@ * */ +#include #include #include #include @@ -228,8 +229,16 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_timerfd_runtime) do { r = epoll_wait(interval_poll_fd, e, sizeof(e) / sizeof(e[0]), 1000); - if (r < 0) + if (r < 0) { + /* if we had an interrupted system call due to process pause via SIGSTOP, do not exit the timer loop */ + if (errno == EINTR) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "epoll_wait interrupted by SIGINT, continue...\n"); + continue; + } + break; + } + for (i = 0; i < r; i++) { it = e[i].data.ptr; if ((e[i].events & EPOLLIN) && From 49f124084915814dfba9249ceca8839caf5a98fa Mon Sep 17 00:00:00 2001 From: Aron Podrigal Date: Wed, 15 Jan 2025 11:51:07 -0600 Subject: [PATCH 2/3] Fix unnecessary whitespace in mod_timerfd.c Removed trailing whitespace to improve code formatting. --- src/mod/timers/mod_timerfd/mod_timerfd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mod/timers/mod_timerfd/mod_timerfd.c b/src/mod/timers/mod_timerfd/mod_timerfd.c index dfd946d6b89..5570bd51e4f 100644 --- a/src/mod/timers/mod_timerfd/mod_timerfd.c +++ b/src/mod/timers/mod_timerfd/mod_timerfd.c @@ -235,7 +235,7 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_timerfd_runtime) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "epoll_wait interrupted by SIGINT, continue...\n"); continue; } - + break; } From 9c939868bbefca11405ee35f59c116406399265c Mon Sep 17 00:00:00 2001 From: Aron Podrigal Date: Wed, 15 Jan 2025 15:27:01 -0600 Subject: [PATCH 3/3] Update mod_timerfd.c switch.h to be first --- src/mod/timers/mod_timerfd/mod_timerfd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mod/timers/mod_timerfd/mod_timerfd.c b/src/mod/timers/mod_timerfd/mod_timerfd.c index 5570bd51e4f..641bfba9c5b 100644 --- a/src/mod/timers/mod_timerfd/mod_timerfd.c +++ b/src/mod/timers/mod_timerfd/mod_timerfd.c @@ -30,8 +30,8 @@ * */ -#include #include +#include #include #include