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