[sheepdog] [PATCH] sheep: fix forward_read_obj_req()

Liu Yuan namei.unix at gmail.com
Fri Jun 29 15:23:54 CEST 2012


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

We shouldn't reset the header if it is the last try or the response will get a
wrong err code in failure.

Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
 sheep/gateway.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/sheep/gateway.c b/sheep/gateway.c
index 27660f1..cda1309 100644
--- a/sheep/gateway.c
+++ b/sheep/gateway.c
@@ -89,9 +89,11 @@ read_remote:
 			eprintf("remote read fail %x\n", ret);
 			sheep_put_sockfd(&v->nid, sfd);
 		}
-		/* Reset the hdr for next read */
-		memcpy(&fwd_hdr, &req->rq, sizeof(fwd_hdr));
-		fwd_hdr.flags |= SD_FLAG_CMD_IO_LOCAL;
+		if (i + 1 != nr_copies) {
+			/* Reset the hdr for next read */
+			memcpy(&fwd_hdr, &req->rq, sizeof(fwd_hdr));
+			fwd_hdr.flags |= SD_FLAG_CMD_IO_LOCAL;
+		}
 	}
 	return ret;
 }
-- 
1.7.10.2




More information about the sheepdog mailing list