Set receive-maximum to not exceed the -C message count.

This is for mosquitto_sub and mosquitto_rr, to avoid potentially lost
messages.

Closes #2134. Thanks to Frantisek Fuka.
This commit is contained in:
Roger Light 2021-03-14 19:24:56 +00:00
parent 9f21a43eee
commit 9faf89be8d
2 changed files with 15 additions and 0 deletions

View File

@ -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 2.0.9 - 2021-03-11
================== ==================

View File

@ -1321,6 +1321,13 @@ int client_opts_set(struct mosquitto *mosq, struct mosq_config *cfg)
if(cfg->tcp_nodelay){ if(cfg->tcp_nodelay){
mosquitto_int_option(mosq, MOSQ_OPT_TCP_NODELAY, 1); 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; return MOSQ_ERR_SUCCESS;
} }