]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[mod_timerfd] Fixed - continue timer loop after receiving a SIGSTOP
authorAron Podrigal <aronp@guaranteedplus.com>
Thu, 16 Jan 2025 16:13:31 +0000 (10:13 -0600)
committerGitHub <noreply@github.com>
Thu, 16 Jan 2025 16:13:31 +0000 (19:13 +0300)
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

index bd07be8cdda1708d17998138d8e21295ca7dafde..641bfba9c5b383db96fddeb1f39037ca07c597ce 100644 (file)
@@ -31,6 +31,7 @@
  */
 
 #include <switch.h>
+#include <errno.h>
 #include <sys/timerfd.h>
 #include <sys/epoll.h>
 
@@ -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) &&