Merge branch 'collectd-5.6' into collectd-5.7
authorMarc Fournier <marc.fournier@camptocamp.com>
Mon, 23 Jan 2017 19:05:30 +0000 (20:05 +0100)
committerMarc Fournier <marc.fournier@camptocamp.com>
Mon, 23 Jan 2017 19:05:30 +0000 (20:05 +0100)
1  2 
src/mqtt.c

diff --combined src/mqtt.c
@@@ -448,6 -448,7 +448,7 @@@ static int publish(mqtt_client_conf_t *
       * 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 +462,7 @@@ static int format_topic(char *buf, size
                          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));
    if ((status < 0) || (((size_t)status) >= buf_len))
      return (ENOMEM);
  
+   while((c = strchr(buf, '#')) || (c = strchr(buf, '+'))) {
+        *c = '_';
+   }
    return (0);
  } /* int format_topic */
  
@@@ -603,9 -609,9 +609,9 @@@ static int mqtt_config_publisher(oconfi
    }
  
    ssnprintf(cb_name, sizeof(cb_name), "mqtt/%s", conf->name);
 -  user_data_t user_data = {.data = conf};
 -
 -  plugin_register_write(cb_name, mqtt_write, &user_data);
 +  plugin_register_write(cb_name, mqtt_write, &(user_data_t){
 +                                                 .data = conf,
 +                                             });
    return (0);
  } /* mqtt_config_publisher */
  
@@@ -734,8 -740,7 +740,8 @@@ static int mqtt_init(void) 
      status = plugin_thread_create(&subscribers[i]->thread,
                                    /* attrs = */ NULL,
                                    /* func  = */ subscribers_thread,
 -                                  /* args  = */ subscribers[i]);
 +                                  /* args  = */ subscribers[i],
 +                                  /* name  = */ "mqtt");
      if (status != 0) {
        char errbuf[1024];
        ERROR("mqtt plugin: pthread_create failed: %s",