src/graph_list.c: Clear instances (again) before scanning the file system.
[collection4.git] / src / graph_list.c
index b405476..02c7de8 100644 (file)
@@ -780,8 +780,8 @@ int gl_config_submit (void) /* {{{ */
   return (0);
 } /* }}} int graph_config_submit */
 
-int gl_graph_get_all (graph_callback_t callback, /* {{{ */
-    void *user_data)
+int gl_graph_get_all (_Bool include_dynamic, /* {{{ */
+    graph_callback_t callback, void *user_data)
 {
   size_t i;
 
@@ -799,6 +799,9 @@ int gl_graph_get_all (graph_callback_t callback, /* {{{ */
       return (status);
   }
 
+  if (!include_dynamic)
+    return (0);
+
   for (i = 0; i < gl_dynamic_num; i++)
   {
     int status;
@@ -1084,6 +1087,11 @@ int gl_update (_Bool request_served) /* {{{ */
   if ((status != 0)
       || ((gl_last_update + UPDATE_INTERVAL) < now))
   {
+    /* Clear state */
+    gl_clear_instances ();
+    gl_clear_hosts ();
+    gl_destroy (&gl_dynamic, &gl_dynamic_num);
+
     status = fs_scan (/* callback = */ gl_register_file,
         /* user data = */ NULL);
     gl_last_update = now;