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

Liu Yuan namei.unix at gmail.com
Mon Dec 10 09:55:45 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>
---
 v2: put eprintf() in a better place.

 sheep/request.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/sheep/request.c b/sheep/request.c
index 9c8f92b..cd81e36 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"
@@ -473,7 +474,10 @@ again:
 	ret = eventfd_read(req->wait_efd, &value);
 	if (ret < 0) {
 		eprintf("%m\n");
-		goto again;
+		if (errno == EINTR)
+			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