From fb4247bf3db6939bcc9a3d9cdbed69e02eb630ea Mon Sep 17 00:00:00 2001
From: "nevadita.chatterjee" <nevadita.chatterjee@iopsys.eu>
Date: Tue, 4 Aug 2020 15:01:31 +0530
Subject: [PATCH] map-topology:Fixed status timer start and refresh interval

---
 README.md           | 2 +-
 src/topo_ieee1905.c | 5 +++++
 src/topologyd.c     | 8 ++------
 src/topologyd.h     | 2 +-
 4 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/README.md b/README.md
index c4160a5..319065f 100644
--- a/README.md
+++ b/README.md
@@ -47,7 +47,7 @@ map-topology provides the `topology` UBUS object with following methods :
 'topology' @fc2af0e9
         "refresh":{}
         "status":{}
-        "refresh":{}
+        "dump":{}
         "changelog":{}
 ````
 
diff --git a/src/topo_ieee1905.c b/src/topo_ieee1905.c
index 94811d7..011d5ae 100644
--- a/src/topo_ieee1905.c
+++ b/src/topo_ieee1905.c
@@ -175,10 +175,12 @@ void topologyd_algo_run(struct topologyd_private *priv)
 			topologyd_send_ieee1905_topology_query(priv, NULL);
 
 		dbg("Processing " MACFMT " AL\n", MAC2STR(p->hwaddr));
+		dbg("The total nodes are %d", p->nbr_num);
 
 		for (j = 0; j < p->nbr_num; j++) {
 			dbg("sending req to " MACFMT "\n", MAC2STR(p->nbrlist[j]));
 			topologyd_send_ieee1905_topology_query(priv, p->nbrlist[j]);
+			dbg("Processing " MACFMT " AL\n", MAC2STR(p->nbrlist[j]));
 		}
 	}
 
@@ -199,6 +201,9 @@ void topologyd_algo_run(struct topologyd_private *priv)
 	}
 
 	priv->algo_running = false;
+	
+	if (priv->status == 0)
+		uloop_timeout_set(&priv->status_timer, TOPOLOGY_STATUS_INTERVAL*1000);
 
 	dbg("\n====== Done Building Topology======\n");
 }
diff --git a/src/topologyd.c b/src/topologyd.c
index 0a6e2f0..3c21c59 100644
--- a/src/topologyd.c
+++ b/src/topologyd.c
@@ -23,7 +23,6 @@
 #include "json_utils.h"
 
 static int signal_pending;
-extern int refresh_int;
 extern const char *ubus_socket;
 uint32_t topology_log_max;
 
@@ -406,8 +405,8 @@ static void topologyd_periodic_refresh(struct uloop_timeout *t)
 
 	topologyd_algo_run(priv);
 
-	if (priv->refresh_int)
-		uloop_timeout_set(&priv->refresh_timer, priv->refresh_int * 1000);
+	if (priv->config.refresh_int)
+		uloop_timeout_set(&priv->refresh_timer, priv->config.refresh_int * 1000);
 }
 
 static void topologyd_change_status(struct uloop_timeout *t)
@@ -454,12 +453,9 @@ static int topologyd_run(struct topologyd_private *priv)
 		return -1;
 	}
 
-	if(priv->refresh_int == 0)
-		priv->refresh_int = TOPOLOGY_REFRESH_INT;
 	
 	topologyd_start_heartbeat(&priv->heartbeat);
 	topologyd_periodic_refresh(&priv->refresh_timer);
-	uloop_timeout_set(&priv->status_timer, 90*1000);
 
 	//initalize the changelog values
 	priv->topo.changelog_front = priv->topo.changelog_rear = -1;
diff --git a/src/topologyd.h b/src/topologyd.h
index 293918a..41b9014 100644
--- a/src/topologyd.h
+++ b/src/topologyd.h
@@ -22,6 +22,7 @@
 #define TOPOLOGY_NODE_MAX	32
 #define TOPOLOGY_NEIGHBOR_MAX	32
 #define TOPOLOGY_VALIDITY	120   // 120 sec
+#define TOPOLOGY_STATUS_INTERVAL 5
 
 typedef uint32_t ieee1905_object_t;
 
@@ -77,7 +78,6 @@ struct topologyd_config {
 
 struct topologyd_private {
 	int debug;
-	uint32_t refresh_int;
 	bool algo_running;
 	enum { INCOMPLETE, AVAILABLE } status;
 	struct ubus_context *ctx;
-- 
GitLab