X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fvarnish.c;h=aee72471a4d6b62d8e8d13266b47e8ff742b34a0;hb=5c2993e4121feae745551be182221b31bc23ff97;hp=682e362fcf301a82b788bcdb0824d1deb8984c82;hpb=9b7dee8838f56233cea2854a7ddbcad2790609ce;p=collectd.git diff --git a/src/varnish.c b/src/varnish.c index 682e362f..aee72471 100644 --- a/src/varnish.c +++ b/src/varnish.c @@ -793,6 +793,7 @@ static int varnish_read (user_data_t *ud) /* {{{ */ { struct VSM_data *vd; const c_varnish_stats_t *stats; + _Bool ok; user_config_t *conf; @@ -822,10 +823,11 @@ static int varnish_read (user_data_t *ud) /* {{{ */ } #if HAVE_VARNISH_V3 - if (VSC_Open (vd, /* diag = */ 1)) + ok = (VSC_Open (vd, /* diag = */ 1) == 0); #else /* if HAVE_VARNISH_V4 */ - if (VSM_Open (vd)) + ok = (VSM_Open (vd) == 0); #endif + if (!ok) { VSM_Delete (vd); ERROR ("varnish plugin: Unable to open connection."); @@ -957,7 +959,7 @@ static int varnish_init (void) /* {{{ */ plugin_register_complex_read (/* group = */ "varnish", /* name = */ "varnish/localhost", /* callback = */ varnish_read, - /* interval = */ NULL, + /* interval = */ 0, /* user data = */ &ud); return (0); @@ -1000,6 +1002,7 @@ static int varnish_config_instance (const oconfig_item_t *ci) /* {{{ */ { WARNING ("Varnish plugin: \"Instance\" blocks accept only " "one argument."); + sfree (conf); return (EINVAL); } @@ -1107,6 +1110,7 @@ static int varnish_config_instance (const oconfig_item_t *ci) /* {{{ */ WARNING ("Varnish plugin: No metric has been configured for " "instance \"%s\". Disabling this instance.", (conf->instance == NULL) ? "localhost" : conf->instance); + sfree (conf); return (EINVAL); } @@ -1119,7 +1123,7 @@ static int varnish_config_instance (const oconfig_item_t *ci) /* {{{ */ plugin_register_complex_read (/* group = */ "varnish", /* name = */ callback_name, /* callback = */ varnish_read, - /* interval = */ NULL, + /* interval = */ 0, /* user data = */ &ud); have_instance = 1;