Fix max_keepalive option not applying to keepalive=0.

Closes #2117. Thanks to David Nadlinger.
This commit is contained in:
Roger A. Light 2021-03-11 19:57:51 +00:00
parent 1109f53fbf
commit 891be8c2fe
2 changed files with 5 additions and 1 deletions

View File

@ -22,6 +22,8 @@ Broker:
- Fix bridge increasing backoff calculation.
- Improve handling of invalid combinations of listener address and bind
interface configurations. Closes #2081.
- Fix `max_keepalive` option not applying to clients connecting with keepalive
set to 0. Closes #2117.
Client library:
- Fix encrypted connections incorrectly connecting when the CA file passed to

View File

@ -244,7 +244,9 @@ int connect__on_authorised(struct mosquitto *context, void *auth_data_out, uint1
goto error;
}
}
if(context->keepalive > db.config->max_keepalive){
if(db.config->max_keepalive &&
(context->keepalive > db.config->max_keepalive || context->keepalive == 0)){
context->keepalive = db.config->max_keepalive;
if(mosquitto_property_add_int16(&connack_props, MQTT_PROP_SERVER_KEEP_ALIVE, context->keepalive)){
rc = MOSQ_ERR_NOMEM;