[sheepdog] [PATCH 2/7] net: clean up clear_client()

Liu Yuan namei.unix at gmail.com
Wed Jul 18 11:35:35 CEST 2012


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

- rename it to clear_client_info()
- move dprintf in it instead of call dprintf every time after clear_client()
- we don't need call free_request(req), because clear_client() already does it.

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

diff --git a/sheep/sdnet.c b/sheep/sdnet.c
index 00ec065..a43a04f 100644
--- a/sheep/sdnet.c
+++ b/sheep/sdnet.c
@@ -391,7 +391,7 @@ static void requeue_request(struct request *req)
 	queue_request(req);
 }
 
-static void clear_client(struct client_info *ci);
+static void clear_client_info(struct client_info *ci);
 
 static struct request *alloc_local_request(void *data, int data_length)
 {
@@ -491,13 +491,10 @@ void put_request(struct request *req)
 		req->done = 1;
 		eventfd_write(req->wait_efd, value);
 	} else {
-		if (conn_tx_on(&ci->conn)) {
-			dprintf("connection seems to be dead\n");
-			free_request(req);
-			clear_client(ci);
-		} else {
+		if (conn_tx_on(&ci->conn))
+			clear_client_info(ci);
+		else
 			list_add(&req->request_list, &ci->done_reqs);
-		}
 	}
 }
 
@@ -662,10 +659,12 @@ static void destroy_client(struct client_info *ci)
 	free(ci);
 }
 
-static void clear_client(struct client_info *ci)
+static void clear_client_info(struct client_info *ci)
 {
 	struct request *req, *t;
 
+	dprintf("connection seems to be dead\n");
+
 	if (ci->rx_req) {
 		free_request(ci->rx_req);
 		ci->rx_req = NULL;
@@ -745,8 +744,7 @@ static void client_handler(int fd, int events, void *data)
 
 	if (is_conn_dead(&ci->conn)) {
 err:
-		dprintf("connection seems to be dead\n");
-		clear_client(ci);
+		clear_client_info(ci);
 	}
 }
 
-- 
1.7.10.2




More information about the sheepdog mailing list