From: Florian Forster Date: Wed, 27 Feb 2008 08:29:17 +0000 (+0100) Subject: network plugin: Add a `flush' callback. X-Git-Tag: collectd-4.4.0~87^2~4^2~4 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=9c3040796e466c3fe4d482b7c87ae1c6053d0941;p=collectd.git network plugin: Add a `flush' callback. --- diff --git a/src/network.c b/src/network.c index 34cf0181..618bf523 100644 --- a/src/network.c +++ b/src/network.c @@ -1602,9 +1602,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 */