Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure socketpairR/W ARE initialized as INVALID_SOCKET #2327

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
2.0.13 - 2021-xx-xx
===================

Broker:
- Fix `max_keepalive` option not being able to be set to 0.
- Fix LWT messages not being delivered if `per_listener_settings` was set to
true. Closes #2314.
- Various fixes around inflight quota management. Closes #2306.
- Fix problem parsing config files with Windows line endings. Closes #2297.


2.0.12 - 2021-08-31
===================

Expand Down
12 changes: 12 additions & 0 deletions apps/db_dump/stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,15 @@ int keepalive__update(struct mosquitto *context)
UNUSED(context);
return 0;
}

void db__msg_add_to_inflight_stats(struct mosquitto_msg_data *msg_data, struct mosquitto_client_msg *msg)
{
UNUSED(msg_data);
UNUSED(msg);
}

void db__msg_add_to_queued_stats(struct mosquitto_msg_data *msg_data, struct mosquitto_client_msg *msg)
{
UNUSED(msg_data);
UNUSED(msg);
}
2 changes: 2 additions & 0 deletions lib/mosquitto.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ int mosquitto_reinitialise(struct mosquitto *mosq, const char *id, bool clean_st
}
mosq->protocol = mosq_p_mqtt311;
mosq->sock = INVALID_SOCKET;
mosq->sockpairR = INVALID_SOCKET;
mosq->sockpairW = INVALID_SOCKET;
mosq->keepalive = 60;
mosq->clean_start = clean_start;
if(id){
Expand Down
12 changes: 8 additions & 4 deletions lib/mosquitto_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,14 @@ struct mosquitto_msg_data{
#ifdef WITH_BROKER
struct mosquitto_client_msg *inflight;
struct mosquitto_client_msg *queued;
long msg_bytes;
long msg_bytes12;
int msg_count;
int msg_count12;
long inflight_bytes;
long inflight_bytes12;
int inflight_count;
int inflight_count12;
long queued_bytes;
long queued_bytes12;
int queued_count;
int queued_count12;
#else
struct mosquitto_message_all *inflight;
int queue_len;
Expand Down
10 changes: 9 additions & 1 deletion man/mosquitto.conf.5.xml
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,15 @@ log_timestamp_format %Y-%m-%dT%H:%M:%S
be sent a server keepalive telling them to use
max_keepalive. This only applies to MQTT v5 clients.
The maximum value allowable, and default value, is
65535. Do not set below 10 seconds.</para>
65535.</para>

<para>
Set to 0 to allow clients to set keepalive = 0, which
means no keepalive checks are made and the client will
never be disconnected by the broker if no messages are
received. You should be very sure this is the behaviour
that you want.
</para>

<para>
For MQTT v3.1.1 and v3.1 clients, there is no mechanism
Expand Down
9 changes: 7 additions & 2 deletions mosquitto.conf
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,13 @@
# use the new keepalive value. The max_keepalive option allows you to specify
# that clients may only connect with keepalive less than or equal to this
# value, otherwise they will be sent a server keepalive telling them to use
# max_keepalive. This only applies to MQTT v5 clients. The maximum value
# allowable is 65535. Do not set below 10.
# max_keepalive. This only applies to MQTT v5 clients. The default, and maximum
# value allowable, is 65535.
#
# Set to 0 to allow clients to set keepalive = 0, which means no keepalive
# checks are made and the client will never be disconnected by the broker if no
# messages are received. You should be very sure this is the behaviour that you
# want.
#
# For MQTT v3.1.1 and v3.1 clients, there is no mechanism to tell the client
# what keepalive value they should use. If an MQTT v3.1.1 or v3.1 client
Expand Down
6 changes: 5 additions & 1 deletion src/conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,10 @@ static int config__read_file_core(struct mosquitto__config *config, bool reload,
}
while((*buf)[slen-1] == 10 || (*buf)[slen-1] == 13){
(*buf)[slen-1] = 0;
slen = strlen(*buf);
if(slen == 0){
continue;
}
}
token = strtok_r((*buf), " ", &saveptr);
if(token){
Expand Down Expand Up @@ -1671,7 +1675,7 @@ static int config__read_file_core(struct mosquitto__config *config, bool reload,
config->max_inflight_messages = (uint16_t)tmp_int;
}else if(!strcmp(token, "max_keepalive")){
if(conf__parse_int(&token, "max_keepalive", &tmp_int, saveptr)) return MOSQ_ERR_INVAL;
if(tmp_int < 10 || tmp_int > UINT16_MAX){
if(tmp_int < 0 || tmp_int > UINT16_MAX){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid max_keepalive value (%d).", tmp_int);
return MOSQ_ERR_INVAL;
}
Expand Down
3 changes: 1 addition & 2 deletions src/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,8 @@ void context__disconnect(struct mosquitto *context)

plugin__handle_disconnect(context, -1);

net__socket_close(context);

context__send_will(context);
net__socket_close(context);
if(context->session_expiry_interval == 0){
/* Client session is due to be expired now */
#ifdef WITH_BRIDGE
Expand Down
Loading