Jelajahi Sumber

cpg: Print cpg name to debug informations

In downlist and joinlist debug output group was printed in nonsense
format of integer to pointer to array.

Now it's printed by full name.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Steven Dake <sdake@redhat.com>
Jan Friesse 13 tahun lalu
induk
melakukan
f3457c5d49
1 mengubah file dengan 37 tambahan dan 4 penghapusan
  1. 37 4
      exec/cpg.c

+ 37 - 4
exec/cpg.c

@@ -317,6 +317,9 @@ static int notify_lib_totem_membership (
 static inline int zcb_all_free (
 static inline int zcb_all_free (
 	struct cpg_pd *cpd);
 	struct cpg_pd *cpd);
 
 
+static char *cpg_print_group_name (
+	const mar_cpg_name_t *group);
+
 /*
 /*
  * Library Handler Definition
  * Library Handler Definition
  */
  */
@@ -476,6 +479,36 @@ struct joinlist_msg {
 
 
 static struct req_exec_cpg_downlist g_req_exec_cpg_downlist;
 static struct req_exec_cpg_downlist g_req_exec_cpg_downlist;
 
 
+/*
+ * Function print group name. It's not reentrant
+ */
+static char *cpg_print_group_name(const mar_cpg_name_t *group)
+{
+	static char res[CPG_MAX_NAME_LENGTH * 4 + 1];
+	int dest_pos = 0;
+	char c;
+	int i;
+
+	for (i = 0; i < group->length; i++) {
+		c = group->value[i];
+
+		if (c >= ' ' && c < 0x7f && c != '\\') {
+			res[dest_pos++] = c;
+                } else {
+			if (c == '\\') {
+				res[dest_pos++] = '\\';
+				res[dest_pos++] = '\\';
+			} else {
+				snprintf(res + dest_pos, sizeof(res) - dest_pos, "\\x%02X", c);
+				dest_pos += 4;
+			}
+		}
+	}
+	res[dest_pos] = 0;
+
+	return (res);
+}
+
 static void cpg_sync_init (
 static void cpg_sync_init (
 	const unsigned int *trans_list,
 	const unsigned int *trans_list,
 	size_t trans_list_entries,
 	size_t trans_list_entries,
@@ -868,8 +901,8 @@ static void downlist_master_choose_and_send (void)
 
 
 		log_printf (LOG_DEBUG, "left_list_entries:%d", pcd->left_list_entries);
 		log_printf (LOG_DEBUG, "left_list_entries:%d", pcd->left_list_entries);
 		for (i=0; i<pcd->left_list_entries; i++) {
 		for (i=0; i<pcd->left_list_entries; i++) {
-			log_printf (LOG_DEBUG, "left_list[%d] group:%d, ip:%s, pid:%d",
-				i, pcd->cpg_group.value,
+			log_printf (LOG_DEBUG, "left_list[%d] group:%s, ip:%s, pid:%d",
+				i, cpg_print_group_name(&group),
 				(char*)api->totem_ifaces_print(pcd->left_list[i].nodeid),
 				(char*)api->totem_ifaces_print(pcd->left_list[i].nodeid),
 				pcd->left_list[i].pid);
 				pcd->left_list[i].pid);
 		}
 		}
@@ -900,8 +933,8 @@ static void joinlist_inform_clients (void)
 
 
 		stored_msg = list_entry(iter, struct joinlist_msg, list);
 		stored_msg = list_entry(iter, struct joinlist_msg, list);
 
 
-		log_printf (LOG_DEBUG, "joinlist_messages[%u] group:%d, ip:%s, pid:%d",
-			i++, stored_msg->group_name.value,
+		log_printf (LOG_DEBUG, "joinlist_messages[%u] group:%s, ip:%s, pid:%d",
+			i++, cpg_print_group_name(&stored_msg->group_name),
 			(char*)api->totem_ifaces_print(stored_msg->sender_nodeid),
 			(char*)api->totem_ifaces_print(stored_msg->sender_nodeid),
 			stored_msg->pid);
 			stored_msg->pid);