Pau Espin Pedrol has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/13281 )

Change subject: Integrate sleeping/printing loop into osmo main loop
......................................................................

Integrate sleeping/printing loop into osmo main loop

Among other possibles issue, it should avoid sporadic print loop hanging if no 
events are fired in osmocom main loop.

Change-Id: Ie2f0983eaf75826483b5b70f58b4d4acb842d6ea
---
M src/osysmon_main.c
1 file changed, 27 insertions(+), 19 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved



diff --git a/src/osysmon_main.c b/src/osysmon_main.c
index c2df6ad..1ba3753 100644
--- a/src/osysmon_main.c
+++ b/src/osysmon_main.c
@@ -35,6 +35,7 @@
 #include <osmocom/core/msgb.h>
 #include <osmocom/core/logging.h>
 #include <osmocom/core/application.h>
+#include <osmocom/core/timer.h>

 static struct log_info log_info = {};

@@ -191,9 +192,31 @@
        }
 }

+static struct osmo_timer_list print_timer;
+int ping_init;
+
+static void print_nodes(__attribute__((unused)) void *data)
+{
+       struct value_node *root = value_node_add(NULL, "root", NULL);
+       osysmon_openvpn_poll(root);
+       osysmon_sysinfo_poll(root);
+       osysmon_ctrl_poll(root);
+       osysmon_rtnl_poll(root);
+
+       if (ping_init == 0)
+               osysmon_ping_poll(root);
+
+       osysmon_file_poll(root);
+
+       display_update(root);
+       value_node_del(root);
+
+       osmo_timer_schedule(&print_timer, 1, 0);
+}
+
 int main(int argc, char **argv)
 {
-       int rc, ping_init;
+       int rc;
 
        osmo_init_logging2(NULL, &log_info);

@@ -231,26 +254,11 @@
                }
        }

-       while (1) {
-               struct value_node *root = value_node_add(NULL, "root", NULL);
-               int vpns = osysmon_openvpn_poll(root);
-               osysmon_sysinfo_poll(root);
-               osysmon_ctrl_poll(root);
-               osysmon_rtnl_poll(root);
+       osmo_timer_setup(&print_timer, print_nodes, NULL);
+       osmo_timer_schedule(&print_timer, 0, 0);

-               if (ping_init == 0)
-                       osysmon_ping_poll(root);
-
-               osysmon_file_poll(root);
-
-               display_update(root);
-               value_node_del(root);
-
-               if (vpns)
+       while (1)
                        osmo_select_main(0);

-               sleep(1);
-       }
-
        exit(0);
 }

--
To view, visit https://gerrit.osmocom.org/13281
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-sysmon
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie2f0983eaf75826483b5b70f58b4d4acb842d6ea
Gerrit-Change-Number: 13281
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol <[email protected]>
Gerrit-Reviewer: Harald Welte <[email protected]>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Pau Espin Pedrol <[email protected]>

Reply via email to