[master] 765b6d3 Restart epoll_wait on EINTR error
Martin Blix Grydeland
martin at varnish-software.com
Fri Dec 4 13:13:23 CET 2015
commit 765b6d3b3bb6f96e2c5945abe998ba9016327116
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