From: Fabien Wernli Date: Tue, 15 May 2012 11:59:10 +0000 (+0200) Subject: Cleanup modbus connection if wrong result X-Git-Tag: collectd-5.3.1~4^2~6 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=06e9e7692aa0d1df7744cca4e70ea404eb25b093;p=collectd.git Cleanup modbus connection if wrong result Change-Id: I1b7520442d7663d5bc2529369e27e3e858fe2168 Signed-off-by: Florian Forster --- diff --git a/src/modbus.c b/src/modbus.c index b5bd75b5..f40258d0 100644 --- a/src/modbus.c +++ b/src/modbus.c @@ -466,8 +466,15 @@ static int mb_read_data (mb_host_t *host, mb_slave_t *slave, /* {{{ */ /* num_registers = */ values_num, /* buffer = */ values); if (status != values_num) { - ERROR ("Modbus plugin: modbus_read_registers (%s) failed. " - "Giving up.", host->host); + ERROR ("Modbus plugin: modbus_read_registers (%s/%s) failed. status = %i, values_num = %i " + "Giving up.", host->host, host->node, status, values_num); +#if LEGACY_LIBMODBUS + modbus_close (&host->connection); +#else + modbus_close (host->connection); + modbus_free (host->connection); +#endif + host->connection = NULL; return (-1); }