aboutsummaryrefslogtreecommitdiffhomepage
path: root/backends
diff options
context:
space:
mode:
authorcbdev <cb@cbcdn.com>2021-09-23 23:11:20 +0200
committercbdev <cb@cbcdn.com>2021-09-23 23:11:20 +0200
commit74c1dd3b84ba9b700b60e5df99d8be265c776946 (patch)
tree4d5a37c4bc2d6f2067aeba1842b4f523b48e64a8 /backends
parentaf27b3e9640421c8c5c01e358a89b4a797242f17 (diff)
downloadmidimonster-74c1dd3b84ba9b700b60e5df99d8be265c776946.tar.gz
midimonster-74c1dd3b84ba9b700b60e5df99d8be265c776946.tar.bz2
midimonster-74c1dd3b84ba9b700b60e5df99d8be265c776946.zip
Fix MQTT instance id generation on Windows
Diffstat (limited to 'backends')
-rw-r--r--backends/mqtt.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/backends/mqtt.c b/backends/mqtt.c
index 6bc366e..6d25fd3 100644
--- a/backends/mqtt.c
+++ b/backends/mqtt.c
@@ -121,7 +121,7 @@ static int mqtt_generate_instanceid(instance* inst){
mqtt_instance_data* data = (mqtt_instance_data*) inst->impl;
char clientid[24] = "";
- snprintf(clientid, sizeof(clientid), "MIDIMonster-%d-%s", (uint32_t) time(NULL), inst->name);
+ snprintf(clientid, sizeof(clientid) - 1, "MM-%s-%d", inst->name, (uint32_t) time(NULL));
return mmbackend_strdup(&(data->client_id), clientid);
}
@@ -287,6 +287,11 @@ static int mqtt_reconnect(instance* inst){
return 2;
}
+ if(!data->client_id && mqtt_generate_instanceid(inst)){
+ LOGPF("Failed to generate instance ID for %s", inst->name);
+ return 2;
+ }
+
if(data->fd >= 0){
mqtt_disconnect(inst);
}
@@ -456,9 +461,6 @@ static int mqtt_configure_instance(instance* inst, char* option, char* value){
mmbackend_strdup(&(data->client_id), value);
return 0;
}
- else{
- return mqtt_generate_instanceid(inst);
- }
}
else if(!strcmp(option, "protocol")){
data->mqtt_version = MQTT_VERSION_DEFAULT;
@@ -518,9 +520,6 @@ static int mqtt_instance(instance* inst){
data->current_alias = 1;
inst->impl = data;
- if(mqtt_generate_instanceid(inst)){
- return 1;
- }
return 0;
}