[Sheepdog] [PATCH] make print_node_list() macro

FUJITA Tomonori fujita.tomonori at lab.ntt.co.jp
Fri Apr 9 05:31:36 CEST 2010


We can know exactly who call print_node_list():

Apr 09 12:27:45 update_cluster_info(551)   nodeid: 1004c0a, pid: 20692, ip: 10.76.0.1:7002
Apr 09 12:27:45 update_cluster_info(551)   nodeid: 1004c0a, pid: 20701, ip: 10.76.0.1:7003
Apr 09 12:27:45 update_cluster_info(551)   nodeid: 1004c0a, pid: 20710, ip: 10.76.0.1:7004
Apr 09 12:27:45 update_cluster_info(551)   nodeid: 1004c0a, pid: 20719, ip: 10.76.0.1:7005
Apr 09 12:27:45 update_cluster_info(551)   nodeid: 1004c0a, pid: 20728, ip: 10.76.0.1:7006
Apr 09 12:27:45 update_cluster_info(551)   nodeid: 1004c0a, pid: 20737, ip: 10.76.0.1:7007
Apr 09 12:27:45 update_cluster_info(551)   nodeid: 1004c0a, pid: 20746, ip: 10.76.0.1:7008

Signed-off-by: FUJITA Tomonori <fujita.tomonori at lab.ntt.co.jp>
---
 collie/group.c |   25 +++++++++++++------------
 1 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/collie/group.c b/collie/group.c
index 5dfd49e..aa43b50 100644
--- a/collie/group.c
+++ b/collie/group.c
@@ -85,6 +85,19 @@ struct work_confch {
 	struct work work;
 };
 
+#define print_node_list(node_list)				\
+({								\
+	struct node *node;					\
+	char name[128];						\
+	list_for_each_entry(node, node_list, list) {		\
+		dprintf("%c nodeid: %x, pid: %d, ip: %s\n",	\
+			is_myself(&node->ent) ? 'l' : ' ',	\
+			node->nodeid, node->pid,		\
+			addr_to_str(name, sizeof(name),		\
+			node->ent.addr, node->ent.port));	\
+	}							\
+})
+
 static int node_cmp(const void *a, const void *b)
 {
 	const struct sheepdog_node_list_entry *node1 = a;
@@ -249,18 +262,6 @@ static void group_handler(int listen_fd, int events, void *data)
 	cpg_dispatch(sys->handle, CPG_DISPATCH_ALL);
 }
 
-static void print_node_list(struct list_head *node_list)
-{
-	struct node *node;
-	char name[128];
-	list_for_each_entry(node, node_list, list) {
-		dprintf("%c nodeid: %x, pid: %d, ip: %s\n",
-			is_myself(&node->ent) ? 'l' : ' ',
-			node->nodeid, node->pid,
-			addr_to_str(name, sizeof(name), node->ent.addr, node->ent.port));
-	}
-}
-
 static void add_node(struct list_head *node_list, uint32_t nodeid, uint32_t pid,
 		     struct sheepdog_node_list_entry *sd_ent)
 {
-- 
1.7.0




More information about the sheepdog mailing list