X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fmqtt.c;h=8a24ccaa0132b6209d58dfcb3de33e728645a54b;hb=a2ddc387687433291c36e7bc8a2f3a5ea88fd0a9;hp=95deb0075bb87540eb3d1b807d93340b94e92d59;hpb=2079ee1517e34de372f58e7e2267ad5c71a8a41f;p=collectd.git diff --git a/src/mqtt.c b/src/mqtt.c index 95deb007..8a24ccaa 100644 --- a/src/mqtt.c +++ b/src/mqtt.c @@ -448,6 +448,7 @@ static int publish(mqtt_client_conf_t *conf, char const *topic, * measure; we will try to reconnect the next time we have to publish a * message */ conf->connected = 0; + mosquitto_disconnect(conf->mosq); pthread_mutex_unlock(&conf->lock); return (-1); @@ -461,6 +462,7 @@ static int format_topic(char *buf, size_t buf_len, data_set_t const *ds, value_list_t const *vl, mqtt_client_conf_t *conf) { char name[MQTT_MAX_TOPIC_SIZE]; int status; + char *c; if ((conf->topic_prefix == NULL) || (conf->topic_prefix[0] == 0)) return (FORMAT_VL(buf, buf_len, vl)); @@ -473,6 +475,10 @@ static int format_topic(char *buf, size_t buf_len, data_set_t const *ds, if ((status < 0) || (((size_t)status) >= buf_len)) return (ENOMEM); + while((c = strchr(buf, '#')) || (c = strchr(buf, '+'))) { + *c = '_'; + } + return (0); } /* int format_topic */