mosquitto
mosquitto copied to clipboard
Publisher: limiting queue size for QoS 1 & 2 messages when publishing while the broker is down
If the broker is down, messages with QoS 1 and QoS 2 are stored in a queue when using mosquitto_publish
mosquitto.h
struct mosquitto
struct mosquitto_msg_data msgs_out;
struct mosquitto_client_msg *queued;
**int queue_len;**
messages_mosq.c
int message__queue(struct mosquitto *mosq, struct mosquitto_message_all *message, enum mosquitto_msg_direction dir)
{
/* mosq->*_message_mutex should be locked before entering this function */
assert(mosq);
assert(message);
assert(message->msg.qos != 0);
if(dir == mosq_md_out){
DL_APPEND(mosq->msgs_out.inflight, message);
**mosq->msgs_out.queue_len++;**
}else{
DL_APPEND(mosq->msgs_in.inflight, message);
mosq->msgs_in.queue_len++;
}
return message__release_to_inflight(mosq, dir);
}
}
Does the library allow setting a limit on the number of QoS 1 and QoS 2 messages stored in the queue when using mosquitto_publish, to prevent excessive memory usage?
Not at the moment, no.