[Sheepdog] [PATCH 4/4] sheep: set poll timeout

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Thu Dec 15 23:01:20 CET 2011


Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 sheep/store.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/sheep/store.c b/sheep/store.c
index 70f9011..43089ce 100644
--- a/sheep/store.c
+++ b/sheep/store.c
@@ -352,11 +352,20 @@ static int forward_write_obj_req(struct request *req)
 
 	ret = SD_RES_SUCCESS;
 again:
-	if (poll(pfds, nr_fds, -1) < 0) {
+	pollret = poll(pfds, nr_fds, DEFAULT_SOCKET_TIMEOUT * 1000);
+	if (pollret < 0) {
 		if (errno == EINTR)
 			goto again;
 
 		ret = SD_RES_EIO;
+	} else if (pollret == 0) { /* poll time out */
+		eprintf("timeout\n");
+
+		for (i = 0; i < nr_fds; i++)
+			del_sheep_fd(pfds[i].fd);
+
+		ret = SD_RES_NETWORK_ERROR;
+		goto out;
 	}
 
 	for (i = 0; i < nr_fds; i++) {
-- 
1.7.2.5




More information about the sheepdog mailing list