Fix bridges incorrectly setting Wills to manage remote notifications.

This is for when `notifications_local_only` was set true.

Closes #1902. Thanks to marcinkowskip.
This commit is contained in:
Roger A. Light 2020-12-01 14:27:54 +00:00
parent 7d05f70fe1
commit 0c22f475ff
3 changed files with 15 additions and 13 deletions

View File

@ -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

View File

@ -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);

View File

@ -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, &notification_payload, 1, true, NULL);
if(rc != MOSQ_ERR_SUCCESS){
return rc;
}
notification_payload = '0';
rc = will__set(context, context->bridge->notification_topic, 1, &notification_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, &notification_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, &notification_payload, 1, true, NULL);
if(rc != MOSQ_ERR_SUCCESS){
mosquitto__free(notification_topic);
return rc;
}
mosquitto__free(notification_topic);
}