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

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