From 8f39176ffc328826ca008b26e56e7b57747dc486 Mon Sep 17 00:00:00 2001
From: Filip Matusiak <filip.matusiak@iopsys.eu>
Date: Wed, 4 Dec 2024 10:49:25 +0100
Subject: [PATCH] Skip getting metrics on nodes with no sta connected

---
 src/cntlr.c     | 4 +++-
 src/cntlr_map.c | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/cntlr.c b/src/cntlr.c
index e9a54ce5..c9a5af95 100644
--- a/src/cntlr.c
+++ b/src/cntlr.c
@@ -1231,6 +1231,9 @@ static void forall_node_get_sta_metrics(struct controller *c)
 	list_for_each_entry(n, &c->nodelist, list) {
 		struct sta *s = NULL;
 
+		if (!n->sta_count || list_empty(&n->stalist))
+			continue;
+
 		list_for_each_entry(s, &n->stalist, list) {
 			struct cmdu_buff *cmdu;
 
@@ -2232,7 +2235,6 @@ static void cntlr_metric_collection(struct controller *c)
 
 	forall_node_get_sta_metrics(c);
 
-
 	/* TODO: */
 	//forall_node_get_usta_metrics(c);
 
diff --git a/src/cntlr_map.c b/src/cntlr_map.c
index 603e7dd2..aef3dc55 100644
--- a/src/cntlr_map.c
+++ b/src/cntlr_map.c
@@ -4442,7 +4442,7 @@ int cntlr_handle_map_event(void *module, uint16_t cmdutype, uint16_t mid,
 			return -1;
 	}
 
-	/*update the timestamp of the node*/
+	/* update the timestamp of the node */
 	if (n)
 		timestamp_update(&n->last_tsp_seen);
 
-- 
GitLab