From: viulian Date: Tue, 27 Mar 2018 22:00:57 +0000 (+0200) Subject: fix the case where libmosquitto doesn't have the second argument in mosquitto_loop... X-Git-Tag: collectd-5.12.0~44^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9e67da61b668f9091ec8de1910e925475f3343c9;p=thirdparty%2Fcollectd.git fix the case where libmosquitto doesn't have the second argument in mosquitto_loop call --- diff --git a/src/mqtt.c b/src/mqtt.c index 09060dfa7..5c1ff1909 100644 --- a/src/mqtt.c +++ b/src/mqtt.c @@ -445,9 +445,13 @@ static int publish(mqtt_client_conf_t *conf, char const *topic, return -1; } - // -1 means default timeout, 1000ms - // second argument is unused, set to 1 for future compatibility - status = mosquitto_loop(conf->mosq, -1, 1); + #if LIBMOSQUITTO_MAJOR == 0 + status = mosquitto_loop(conf->mosq, /* timeout = */ 1000 /* ms */); + #else + status = mosquitto_loop(conf->mosq, + /* timeout[ms] = */ 1000, + /* max_packets = */ 1); + #endif if (status != MOSQ_ERR_SUCCESS) { c_complain(LOG_ERR, &conf->complaint_cantpublish,