Skip to content

Commit

Permalink
Fix max_keepalive option not applying to keepalive=0.
Browse files Browse the repository at this point in the history
Closes #2117. Thanks to David Nadlinger.
  • Loading branch information
ralight committed Mar 11, 2021
1 parent 1109f53 commit 891be8c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ChangeLog.txt
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/handle_connect.c
Expand Up @@ -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;
Expand Down

0 comments on commit 891be8c

Please sign in to comment.