[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-devel] [bug #59313] Possible faulty behavoir in mqtt_close() funct
From: |
Christian Schlotter |
Subject: |
[lwip-devel] [bug #59313] Possible faulty behavoir in mqtt_close() function |
Date: |
Tue, 28 Sep 2021 09:16:27 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36 |
Follow-up Comment #2, bug #59313 (project lwip):
I can confirm Ondrej's code change works, but we would suggest adding the code
to mqtt_disconnect() (instead of mqtt_close()):
diff --git a/Firmware/lwip-STABLE-2_1_2_RELEASE/src/apps/mqtt/mqtt.c
b/Firmware/lwip-STABLE-2_1_2_RELEASE/src/apps/mqtt/mqtt.c
index 269f4a4..ce640b8 100644
--- a/Firmware/lwip-STABLE-2_1_2_RELEASE/src/apps/mqtt/mqtt.c
+++ b/Firmware/lwip-STABLE-2_1_2_RELEASE/src/apps/mqtt/mqtt.c
@@ -1440,6 +1440,10 @@ mqtt_disconnect(mqtt_client_t *client)
LWIP_ASSERT("mqtt_disconnect: client != NULL", client);
/* If connection in not already closed */
if (client->conn_state != TCP_DISCONNECTED) {
+ if (mqtt_output_check_space(&client->output, 0) != 0) {
+ mqtt_output_append_fixed_header(&client->output,
MQTT_MSG_TYPE_DISCONNECT, 0, 0, 0, 0);
+ mqtt_output_send(&client->output, client->conn);
+ }
/* Set conn_state before calling mqtt_close to prevent callback from
being called */
client->conn_state = TCP_DISCONNECTED;
mqtt_close(client, (mqtt_connection_status_t)0);
I think it would be important to include this in v2.1.3, as this is fixing an
important deviation from the MQTT spec.
_______________________________________________________
Reply to this item at:
<https://savannah.nongnu.org/bugs/?59313>
_______________________________________________
Message sent via Savannah
https://savannah.nongnu.org/