X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fdaemon%2Fplugin.c;h=c6efc3fe439b35ed396b22a391938e2af98c6e3c;hb=b847e8ff2fd928813397466a941947c8fce66d66;hp=2ccc68c21ccc2d1fa566b602e0186085baae718a;hpb=f8e1e81d433c5b4e06792c2617abf0e6ec9e76d9;p=collectd.git diff --git a/src/daemon/plugin.c b/src/daemon/plugin.c index 2ccc68c2..c6efc3fe 100644 --- a/src/daemon/plugin.c +++ b/src/daemon/plugin.c @@ -1974,10 +1974,10 @@ int plugin_shutdown_all (void) llentry_t *le; int ret = 0; // Assume success. - stop_read_threads (); - destroy_all_callbacks (&list_init); + stop_read_threads (); + pthread_mutex_lock (&read_lock); llist_destroy (read_list); read_list = NULL; @@ -1985,6 +1985,10 @@ int plugin_shutdown_all (void) destroy_read_heap (); + /* blocks until all write threads have shut down. */ + stop_write_threads (); + + /* ask all plugins to write out the state they kept. */ plugin_flush (/* plugin = */ NULL, /* timeout = */ 0, /* identifier = */ NULL); @@ -2015,8 +2019,6 @@ int plugin_shutdown_all (void) plugin_set_ctx (old_ctx); } - stop_write_threads (); - /* Write plugins which use the `user_data' pointer usually need the * same data available to the flush callback. If this is the case, set * the free_function to NULL when registering the flush callback and to @@ -2399,7 +2401,7 @@ int plugin_dispatch_multivalue (value_list_t const *template, /* {{{ */ case DS_TYPE_GAUGE: vl->values[0].gauge = va_arg (ap, gauge_t); if (store_percentage) - vl->values[0].gauge *= sum ? (100.0 / sum) : 0; + vl->values[0].gauge *= sum ? (100.0 / sum) : NAN; break; case DS_TYPE_ABSOLUTE: vl->values[0].absolute = va_arg (ap, absolute_t);