Skip to content

Commit

Permalink
Set receive-maximum to not exceed the -C message count.
Browse files Browse the repository at this point in the history
This is for mosquitto_sub and mosquitto_rr, to avoid potentially lost
messages.

Closes #2134. Thanks to Frantisek Fuka.
  • Loading branch information
ralight committed Mar 14, 2021
1 parent 9f21a43 commit 9faf89b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ChangeLog.txt
@@ -1,3 +1,11 @@
2.0.10 - 2021-xx-xx
==================

Clients:
- Set `receive-maximum` to not exceed the `-C` message count in mosquitto_sub
and mosquitto_rr, to avoid potentially lost messages. Closes #2134.


2.0.9 - 2021-03-11
==================

Expand Down
7 changes: 7 additions & 0 deletions client/client_shared.c
Expand Up @@ -1321,6 +1321,13 @@ int client_opts_set(struct mosquitto *mosq, struct mosq_config *cfg)
if(cfg->tcp_nodelay){
mosquitto_int_option(mosq, MOSQ_OPT_TCP_NODELAY, 1);
}

if(cfg->msg_count > 0 && cfg->msg_count < 20){
/* 20 is the default "receive maximum"
* If we don't set this, then we can receive > msg_count messages
* before we quit.*/
mosquitto_int_option(mosq, MOSQ_OPT_RECEIVE_MAXIMUM, cfg->msg_count);
}
return MOSQ_ERR_SUCCESS;
}

Expand Down

0 comments on commit 9faf89b

Please sign in to comment.