Explorar o código

stats: Don't display errors when reading knet stat

Only add the knet handle stat keys if we are actually running knet. This
prevents errors occurring when iterating through all of the stats keys

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
Christine Caulfield %!s(int64=8) %!d(string=hai) anos
pai
achega
45fe19ed86
Modificáronse 3 ficheiros con 17 adicións e 4 borrados
  1. 12 4
      exec/stats.c
  2. 3 0
      exec/totemknet.c
  3. 2 0
      include/corosync/totem/totemstats.h

+ 12 - 4
exec/stats.c

@@ -280,10 +280,6 @@ cs_error_t stats_map_init(const struct corosync_api_v1 *corosync_api)
 		sprintf(param, "stats.ipcs.%s", cs_ipcs_global_stats[i].name);
 		sprintf(param, "stats.ipcs.%s", cs_ipcs_global_stats[i].name);
 		stats_add_entry(param, &cs_ipcs_global_stats[i]);
 		stats_add_entry(param, &cs_ipcs_global_stats[i]);
 	}
 	}
-	for (i = 0; i<NUM_KNET_HANDLE_STATS; i++) {
-		sprintf(param, "stats.knet.handle.%s", cs_knet_handle_stats[i].name);
-		stats_add_entry(param, &cs_knet_handle_stats[i]);
-	}
 
 
 	/* KNET and IPCS stats are added when appropriate */
 	/* KNET and IPCS stats are added when appropriate */
 	return CS_OK;
 	return CS_OK;
@@ -633,6 +629,18 @@ void stats_knet_del_member(knet_node_id_t nodeid, uint8_t link_no)
 	}
 	}
 }
 }
 
 
+/* This is separated out from  stats_map_init() because we don't know whether
+   knet is in use until much later in the startup */
+void stats_knet_add_handle(void)
+{
+	int i;
+	char param[ICMAP_KEYNAME_MAXLEN];
+
+	for (i = 0; i<NUM_KNET_HANDLE_STATS; i++) {
+		sprintf(param, "stats.knet.handle.%s", cs_knet_handle_stats[i].name);
+		stats_add_entry(param, &cs_knet_handle_stats[i]);
+	}
+}
 
 
 /* Called from ipc_glue to add/remove keys from our map */
 /* Called from ipc_glue to add/remove keys from our map */
 void stats_ipcs_add_connection(int service_id, uint32_t pid, void *ptr)
 void stats_ipcs_add_connection(int service_id, uint32_t pid, void *ptr)

+ 3 - 0
exec/totemknet.c

@@ -953,6 +953,9 @@ int totemknet_initialize (
 	/* Start listening for config changes */
 	/* Start listening for config changes */
 	totemknet_add_config_notifications(instance);
 	totemknet_add_config_notifications(instance);
 
 
+	/* Add stats keys to icmap */
+	stats_knet_add_handle();
+
 	knet_log_printf (LOGSYS_LEVEL_INFO, "totemknet initialized");
 	knet_log_printf (LOGSYS_LEVEL_INFO, "totemknet initialized");
 	*knet_context = instance;
 	*knet_context = instance;
 
 

+ 2 - 0
include/corosync/totem/totemstats.h

@@ -109,6 +109,8 @@ void stats_knet_add_member(knet_node_id_t nodeid, uint8_t link);
 
 
 void stats_knet_del_member(knet_node_id_t nodeid, uint8_t link);
 void stats_knet_del_member(knet_node_id_t nodeid, uint8_t link);
 
 
+void stats_knet_add_handle(void);
+
 #define TOTEMPG_STATS_CLEAR_TOTEM     1
 #define TOTEMPG_STATS_CLEAR_TOTEM     1
 #define TOTEMPG_STATS_CLEAR_TRANSPORT 2
 #define TOTEMPG_STATS_CLEAR_TRANSPORT 2