Skip to content

Commit

Permalink
[mod_timerfd] Fixed - continue timer loop after receiving a SIGSTOP
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ar45 authored Jan 16, 2025
1 parent 55d8f3f commit 96de8fd
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/mod/timers/mod_timerfd/mod_timerfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
*/

#include <switch.h>
#include <errno.h>
#include <sys/timerfd.h>
#include <sys/epoll.h>

Expand Down Expand Up @@ -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) &&
Expand Down

0 comments on commit 96de8fd

Please sign in to comment.