[sheepdog] [PATCH] sheep: fix a sheep hang problem

Liu Yuan namei.unix at gmail.com
Mon Dec 10 09:46:01 CET 2012


From: Liu Yuan <tailai.ly at taobao.com>

We observed that eventfd_read() in exec_local_request() might get 'Bad file
destriptor' and led the sheep daemon hang in 'goto loop'. We can only safely
loop in EINTR cases, for others, let gateway retry the request.

Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
 sheep/request.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/sheep/request.c b/sheep/request.c
index 9c8f92b..ce05359 100644
--- a/sheep/request.c
+++ b/sheep/request.c
@@ -18,6 +18,7 @@
 #include <netinet/tcp.h>
 #include <sys/epoll.h>
 #include <fcntl.h>
+#include <errno.h>
 
 #include "sheep_priv.h"
 #include "util.h"
@@ -472,8 +473,12 @@ again:
 	/* In error case (for e.g, EINTR) just retry read */
 	ret = eventfd_read(req->wait_efd, &value);
 	if (ret < 0) {
-		eprintf("%m\n");
-		goto again;
+		if (errno == EINTR) {
+			eprintf("%m\n");
+			goto again;
+		}
+		/* Fake the result to ask for retry */
+		req->rp.result = SD_RES_NETWORK_ERROR;
 	}
 
 	/* fill rq with response header as exec_req does */
-- 
1.7.9.5




More information about the sheepdog mailing list