[sheepdog] [PATCH 1/2] sheep: add two assertion to clarify the code a bit

Liu Yuan namei.unix at gmail.com
Fri Jun 1 17:17:36 CEST 2012


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

This two cases are actually executed with two different context, adding
two assertion both make code readable and safe.

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

diff --git a/sheep/sdnet.c b/sheep/sdnet.c
index 108fce4..f7054aa 100644
--- a/sheep/sdnet.c
+++ b/sheep/sdnet.c
@@ -262,12 +262,18 @@ void resume_wait_epoch_requests(void)
 
 	list_for_each_entry_safe(req, t, &pending_list, request_list) {
 		switch (req->rp.result) {
-		/* gateway retries to send the request when
-		   its epoch changes. */
 		case SD_RES_OLD_NODE_VER:
+			/*
+			 * Gateway retries to send the request when
+			 * its epoch changes.
+			 */
+			assert(!(req->rq.flags & SD_FLAG_CMD_IO_LOCAL));
 			req->rq.epoch = sys->epoch;
-		/* peer retries the request locally when its epoch changes. */
+			requeue_request(req);
+			break;
 		case SD_RES_NEW_NODE_VER:
+			/* Peer retries the request locally when its epoch changes. */
+			assert(req->rq.flags & SD_FLAG_CMD_IO_LOCAL);
 			requeue_request(req);
 			break;
 		default:
-- 
1.7.10.2




More information about the sheepdog mailing list