Code

network plugin: Don't blindly re-initialize everything in the init callback.
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Sat, 7 Jun 2008 18:39:04 +0000 (20:39 +0200)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Sat, 7 Jun 2008 18:39:04 +0000 (20:39 +0200)
Under Solaris the init functions are called every time the kstat chain
is updated. Since, among other things, send_buffer_fill was set to zero
here, the plugin ``forgot'' about values.

Thank you very much to Eric LeBlanc for debugging this issue.

src/network.c

index b67928c7c2fe6a10aec868ba61c5c7fbe512f6c9..ff806af3a10ac72eaa53a6a4edbd33a0f36b0f6e 100644 (file)
@@ -183,7 +183,7 @@ static pthread_mutex_t send_buffer_lock = PTHREAD_MUTEX_INITIALIZER;
 
 static c_avl_tree_t      *cache_tree = NULL;
 static pthread_mutex_t  cache_lock = PTHREAD_MUTEX_INITIALIZER;
-static time_t           cache_flush_last;
+static time_t           cache_flush_last = 0;
 static int              cache_flush_interval = 1800;
 
 /*
@@ -1706,11 +1706,19 @@ static int network_shutdown (void)
        plugin_unregister_write ("network");
        plugin_unregister_shutdown ("network");
 
+       /* Let the init function do it's move again ;) */
+       cache_flush_last = 0;
+
        return (0);
 } /* int network_shutdown */
 
 static int network_init (void)
 {
+       /* Check if we were already initialized. If so, just return - there's
+        * nothing more to do (for now, that is). */
+       if (cache_flush_last != 0)
+               return (0);
+
        plugin_register_shutdown ("network", network_shutdown);
 
        send_buffer_ptr  = send_buffer;