[sheepdog] [PATCH 3/9] sheep: add a list for storing information of all clients

Hitoshi Mitake mitake.hitoshi at lab.ntt.co.jp
Fri Jun 27 08:13:50 CEST 2014


This is a preparation patch. Currently we don't have a way of
enumerating entire information of clients. This patch adds a single
list for doing it.

Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
 sheep/request.c    |    6 ++++++
 sheep/sheep_priv.h |    2 ++
 2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/sheep/request.c b/sheep/request.c
index e0aa4d5..6a6b61f 100644
--- a/sheep/request.c
+++ b/sheep/request.c
@@ -885,6 +885,7 @@ static void destroy_client(struct client_info *ci)
 {
 	sd_debug("connection from: %s:%d", ci->conn.ipstr, ci->conn.port);
 	close(ci->conn.fd);
+	list_del(&ci->list);
 	free(ci);
 }
 
@@ -910,6 +911,8 @@ static void clear_client_info(struct client_info *ci)
 	destroy_client(ci);
 }
 
+static LIST_HEAD(client_list);
+
 static struct client_info *create_client(int fd, struct cluster_info *cluster)
 {
 	struct client_info *ci;
@@ -944,6 +947,9 @@ static struct client_info *create_client(int fd, struct cluster_info *cluster)
 
 	INIT_LIST_HEAD(&ci->done_reqs);
 
+	INIT_LIST_NODE(&ci->list);
+	list_add_tail(&ci->list, &client_list);
+
 	return ci;
 }
 
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index 2c106ee..fdf07e0 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -75,6 +75,8 @@ struct client_info {
 	struct list_head done_reqs;
 
 	refcnt_t refcnt;
+
+	struct list_node list;
 };
 
 enum REQUST_STATUS {
-- 
1.7.1




More information about the sheepdog mailing list