Blame SOURCES/Add-a-safety-timeout-to-epoll.patch

4bd34d
From b4b7e3fc0f2008967202f2453e9c33b378e7a000 Mon Sep 17 00:00:00 2001
4bd34d
From: Simo Sorce <simo@redhat.com>
4bd34d
Date: Wed, 6 Mar 2019 10:36:11 -0500
4bd34d
Subject: [PATCH] Add a safety timeout to epoll
4bd34d
4bd34d
Add a safety timeout just in case something goes wrong with the use of
4bd34d
timerfd. This way the process should't be stuck forever.
4bd34d
4bd34d
Signed-off-by: Simo Sorce <simo@redhat.com>
4bd34d
[rharwood@redhat.com: remove outdated comment]
4bd34d
Reviewed-by: Robbie Harwood <rharwood@redhat.com>
4bd34d
Merges: #241
4bd34d
(cherry picked from commit d55be9fa2455fe52b6eb904ad427f22141ab3f26)
4bd34d
(cherry picked from commit a494f23b6d8d43fe1a824cd69c3dd93a18fc75a1)
4bd34d
---
4bd34d
 src/client/gpm_common.c | 5 ++---
4bd34d
 1 file changed, 2 insertions(+), 3 deletions(-)
4bd34d
4bd34d
diff --git a/src/client/gpm_common.c b/src/client/gpm_common.c
4bd34d
index 36df5cc..808f350 100644
4bd34d
--- a/src/client/gpm_common.c
4bd34d
+++ b/src/client/gpm_common.c
4bd34d
@@ -14,6 +14,7 @@
4bd34d
 #define FRAGMENT_BIT (1 << 31)
4bd34d
 
4bd34d
 #define RESPONSE_TIMEOUT 15
4bd34d
+#define SAFETY_TIMEOUT RESPONSE_TIMEOUT * 10 * 1000
4bd34d
 #define MAX_TIMEOUT_RETRY 3
4bd34d
 
4bd34d
 struct gpm_ctx {
4bd34d
@@ -291,7 +292,7 @@ static int gpm_epoll_wait(struct gpm_ctx *gpmctx, uint32_t event_flags)
4bd34d
     }
4bd34d
 
4bd34d
     do {
4bd34d
-        epoll_ret = epoll_wait(gpmctx->epollfd, events, 2, -1);
4bd34d
+        epoll_ret = epoll_wait(gpmctx->epollfd, events, 2, SAFETY_TIMEOUT);
4bd34d
     } while (epoll_ret < 0 && errno == EINTR);
4bd34d
 
4bd34d
     if (epoll_ret < 0) {
4bd34d
@@ -299,8 +300,6 @@ static int gpm_epoll_wait(struct gpm_ctx *gpmctx, uint32_t event_flags)
4bd34d
         ret = errno;
4bd34d
         gpm_epoll_close(gpmctx);
4bd34d
     } else if (epoll_ret == 0) {
4bd34d
-        /* Shouldn't happen as timeout == -1; treat it like a timeout
4bd34d
-         * occurred. */
4bd34d
         ret = ETIMEDOUT;
4bd34d
         gpm_epoll_close(gpmctx);
4bd34d
     } else if (epoll_ret == 1 && events[0].data.fd == gpmctx->timerfd) {