Fix inflight max behaviour and option setting.

This commit is contained in:
Roger A. Light 2019-09-24 11:26:25 +01:00
parent 096380fbdc
commit 4b6cc208e2
4 changed files with 13 additions and 9 deletions

View File

@ -6,6 +6,8 @@ Broker:
Client library: Client library:
- Don't use `/` in autogenerated client ids, to avoid confusing with topics. - Don't use `/` in autogenerated client ids, to avoid confusing with topics.
- Fix `mosquitto_max_inflight_messages_set()` and `mosquitto_int_option(...,
MOSQ_OPT_*_MAX, ...)` behaviour. Closes #1417.
Clients: Clients:
- mosquitto_sub: Fix `-E` incorrectly not working unless `-d` was also - mosquitto_sub: Fix `-E` incorrectly not working unless `-d` was also

View File

@ -340,10 +340,6 @@ int message__out_update(struct mosquitto *mosq, uint16_t mid, enum mosquitto_msg
int mosquitto_max_inflight_messages_set(struct mosquitto *mosq, unsigned int max_inflight_messages) int mosquitto_max_inflight_messages_set(struct mosquitto *mosq, unsigned int max_inflight_messages)
{ {
if(!mosq) return MOSQ_ERR_INVAL; return mosquitto_int_option(mosq, MOSQ_OPT_SEND_MAXIMUM, max_inflight_messages);
mosq->send_maximum = max_inflight_messages;
return MOSQ_ERR_SUCCESS;
} }

View File

@ -335,8 +335,6 @@ struct mosquitto {
# ifdef WITH_SRV # ifdef WITH_SRV
ares_channel achan; ares_channel achan;
# endif # endif
uint16_t send_maximum;
uint16_t receive_maximum;
#endif #endif
uint8_t maximum_qos; uint8_t maximum_qos;

View File

@ -409,14 +409,22 @@ int mosquitto_int_option(struct mosquitto *mosq, enum mosq_opt_t option, int val
if(value < 0 || value > 65535){ if(value < 0 || value > 65535){
return MOSQ_ERR_INVAL; return MOSQ_ERR_INVAL;
} }
mosq->receive_maximum = value; if(value == 0){
mosq->msgs_in.inflight_maximum = 65535;
}else{
mosq->msgs_in.inflight_maximum = value;
}
break; break;
case MOSQ_OPT_SEND_MAXIMUM: case MOSQ_OPT_SEND_MAXIMUM:
if(value < 0 || value > 65535){ if(value < 0 || value > 65535){
return MOSQ_ERR_INVAL; return MOSQ_ERR_INVAL;
} }
mosq->send_maximum = value; if(value == 0){
mosq->msgs_out.inflight_maximum = 65535;
}else{
mosq->msgs_out.inflight_maximum = value;
}
break; break;
case MOSQ_OPT_SSL_CTX_WITH_DEFAULTS: case MOSQ_OPT_SSL_CTX_WITH_DEFAULTS: