[4.1] df4ef3b Restart epoll_wait on EINTR error

Lasse Karstensen lkarsten at varnish-software.com
Thu Jan 14 15:15:07 CET 2016


commit df4ef3b99acba107fc69e1d0e07ab262bb2d1ba6
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Fri Dec 4 13:12:05 2015 +0100

    Restart epoll_wait on EINTR error
    
    This works around a Linux kernel bug where the epoll_wait will return
    EINTR when the process is subjected to a ptrace or the OS wakes from
    suspend.
    
    Fixes: #1763

diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c
index cb6dbdc..f50ae46 100644
--- a/bin/varnishd/waiter/cache_waiter_epoll.c
+++ b/bin/varnishd/waiter/cache_waiter_epoll.c
@@ -38,6 +38,7 @@
 #include <sys/epoll.h>
 
 #include <stdlib.h>
+#include <errno.h>
 
 #include "cache/cache.h"
 
@@ -110,7 +111,12 @@ vwe_thread(void *priv)
 		i = (int)ceil(1e3 * then);
 		assert(i > 0);
 		Lck_Unlock(&vwe->mtx);
-		n = epoll_wait(vwe->epfd, ev, NEEV, i);
+		do {
+			/* Due to a linux kernel bug, epoll_wait can
+			   return EINTR when the process is subjected to
+			   ptrace or waking from OS suspend. */
+			n = epoll_wait(vwe->epfd, ev, NEEV, i);
+		} while (n < 0 && errno == EINTR);
 		assert(n >= 0);
 		assert(n <= NEEV);
 		now = VTIM_real();



More information about the varnish-commit mailing list