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