diff --git a/ChangeLog.txt b/ChangeLog.txt index bcc1902c..c1b4a4f6 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -6,6 +6,8 @@ Broker: Client library: - 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: - mosquitto_sub: Fix `-E` incorrectly not working unless `-d` was also diff --git a/lib/messages_mosq.c b/lib/messages_mosq.c index 75e4f860..90262441 100644 --- a/lib/messages_mosq.c +++ b/lib/messages_mosq.c @@ -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) { - if(!mosq) return MOSQ_ERR_INVAL; - - mosq->send_maximum = max_inflight_messages; - - return MOSQ_ERR_SUCCESS; + return mosquitto_int_option(mosq, MOSQ_OPT_SEND_MAXIMUM, max_inflight_messages); } diff --git a/lib/mosquitto_internal.h b/lib/mosquitto_internal.h index da16dae0..5280a77f 100644 --- a/lib/mosquitto_internal.h +++ b/lib/mosquitto_internal.h @@ -335,8 +335,6 @@ struct mosquitto { # ifdef WITH_SRV ares_channel achan; # endif - uint16_t send_maximum; - uint16_t receive_maximum; #endif uint8_t maximum_qos; diff --git a/lib/options.c b/lib/options.c index 483edbb2..4ab8897e 100644 --- a/lib/options.c +++ b/lib/options.c @@ -409,14 +409,22 @@ int mosquitto_int_option(struct mosquitto *mosq, enum mosq_opt_t option, int val if(value < 0 || value > 65535){ 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; case MOSQ_OPT_SEND_MAXIMUM: if(value < 0 || value > 65535){ 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; case MOSQ_OPT_SSL_CTX_WITH_DEFAULTS: