diff --git a/ChangeLog.txt b/ChangeLog.txt index d5d21bbb..c73973f5 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -94,6 +94,8 @@ Broker: - Add `ciphers_tls1.3` option, to allow setting TLS v1.3 ciphersuites. Closes #1825. - Report an error if the config file is set to a directory. Closes #1814. +- Fix bridges incorrectly setting Wills to manage remote notifications when + `notifications_local_only` was set true. Closes #1902. Client library: - Client no longer generates random client ids for v3.1.1 clients, these are diff --git a/lib/send_connect.c b/lib/send_connect.c index 56b46a90..ac4f012b 100644 --- a/lib/send_connect.c +++ b/lib/send_connect.c @@ -100,7 +100,11 @@ int send__connect(struct mosquitto *mosq, uint16_t keepalive, bool clean_session }else{ payloadlen = 2U; } +#ifdef WITH_BROKER + if(mosq->will && (mosq->bridge == NULL || mosq->bridge->notifications_local_only == false)){ +#else if(mosq->will){ +#endif will = 1; assert(mosq->will->msg.topic); diff --git a/src/bridge.c b/src/bridge.c index ef090c72..62ce2354 100644 --- a/src/bridge.c +++ b/src/bridge.c @@ -376,12 +376,10 @@ int bridge__connect(struct mosquitto *context) context->bridge->initial_notification_done = true; } - if (!context->bridge->notifications_local_only) { - notification_payload = '0'; - rc = will__set(context, context->bridge->notification_topic, 1, ¬ification_payload, 1, true, NULL); - if(rc != MOSQ_ERR_SUCCESS){ - return rc; - } + notification_payload = '0'; + rc = will__set(context, context->bridge->notification_topic, 1, ¬ification_payload, 1, true, NULL); + if(rc != MOSQ_ERR_SUCCESS){ + return rc; } }else{ notification_topic_len = strlen(context->bridge->remote_clientid)+strlen("$SYS/broker/connection//state"); @@ -396,13 +394,11 @@ int bridge__connect(struct mosquitto *context) context->bridge->initial_notification_done = true; } - if (!context->bridge->notifications_local_only) { - notification_payload = '0'; - rc = will__set(context, notification_topic, 1, ¬ification_payload, 1, true, NULL); - if(rc != MOSQ_ERR_SUCCESS){ - mosquitto__free(notification_topic); - return rc; - } + notification_payload = '0'; + rc = will__set(context, notification_topic, 1, ¬ification_payload, 1, true, NULL); + if(rc != MOSQ_ERR_SUCCESS){ + mosquitto__free(notification_topic); + return rc; } mosquitto__free(notification_topic); }