[sheepdog] [PATCH 2/3] sheep: now we do not need client_incref/client_decref

Yunkai Zhang yunkai.me at gmail.com
Thu Jul 5 12:34:11 CEST 2012


From: Yunkai Zhang <qiushu.zyk at taobao.com>

Sheep calls client_incref() in alloc_request(), but free_request()
does not call client_desref() in it, as a result it's difficult to
keep client->refcnt with correct value. I have been trying to move
client_desref() into free_request(), but I'm failed as client_desref()
do too more things. I think we can drop it now.

Signed-off-by: Yunkai Zhang <qiushu.zyk at taobao.com>
---
 sheep/sdnet.c      |   16 ----------------
 sheep/sheep_priv.h |    2 --
 2 files changed, 18 deletions(-)

diff --git a/sheep/sdnet.c b/sheep/sdnet.c
index b493428..f5272b3 100644
--- a/sheep/sdnet.c
+++ b/sheep/sdnet.c
@@ -368,8 +368,6 @@ static void requeue_request(struct request *req)
 	queue_request(req);
 }
 
-static void client_incref(struct client_info *ci);
-static void client_decref(struct client_info *ci);
 static void clear_client(struct client_info *ci);
 
 static struct request *alloc_local_request(void *data, int data_length)
@@ -430,7 +428,6 @@ static struct request *alloc_request(struct client_info *ci, int data_length)
 		return NULL;
 
 	req->ci = ci;
-	client_incref(ci);
 	if (data_length) {
 		req->data_length = data_length;
 		req->data = valloc(data_length);
@@ -662,18 +659,6 @@ static void clear_client(struct client_info *ci)
 	destroy_client(ci);
 }
 
-static void client_incref(struct client_info *ci)
-{
-	if (ci)
-		ci->refcnt++;
-}
-
-static void client_decref(struct client_info *ci)
-{
-	if (ci && --ci->refcnt == 0)
-		destroy_client(ci);
-}
-
 static struct client_info *create_client(int fd, struct cluster_info *cluster)
 {
 	struct client_info *ci;
@@ -702,7 +687,6 @@ static struct client_info *create_client(int fd, struct cluster_info *cluster)
 
 	ci->conn.fd = fd;
 	ci->conn.events = EPOLLIN;
-	ci->refcnt = 1;
 
 	INIT_LIST_HEAD(&ci->done_reqs);
 	INIT_LIST_HEAD(&ci->conn.blocking_siblings);
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index afbc361..fb0dba8 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -33,8 +33,6 @@ struct client_info {
 	struct request *tx_req;
 
 	struct list_head done_reqs;
-
-	int refcnt;
 };
 
 struct vnode_info {
-- 
1.7.10.4




More information about the sheepdog mailing list