Code

Merge branch 'collectd-4.3' into collectd-4.4
[collectd.git] / src / network.c
index ff806af3a10ac72eaa53a6a4edbd33a0f36b0f6e..039354b5b44a9e123c3d0a41172161ca8edf96ba 100644 (file)
@@ -1767,9 +1767,25 @@ static int network_init (void)
        return (0);
 } /* int network_init */
 
+static int network_flush (int timeout)
+{
+       pthread_mutex_lock (&send_buffer_lock);
+
+       if (((time (NULL) - cache_flush_last) >= timeout)
+                       && (send_buffer_fill > 0))
+       {
+               flush_buffer ();
+       }
+
+       pthread_mutex_unlock (&send_buffer_lock);
+
+       return (0);
+} /* int network_flush */
+
 void module_register (void)
 {
        plugin_register_config ("network", network_config,
                        config_keys, config_keys_num);
        plugin_register_init   ("network", network_init);
+       plugin_register_flush   ("network", network_flush);
 } /* void module_register */