[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-devel] [bug #59561] [mqtt] Stop sending a keep-alive if the connec
From: |
Giuseppe Modugno |
Subject: |
[lwip-devel] [bug #59561] [mqtt] Stop sending a keep-alive if the connection is closed for a previously unacked keep-alive |
Date: |
Fri, 27 Nov 2020 12:38:27 -0500 (EST) |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36 |
URL:
<https://savannah.nongnu.org/bugs/?59561>
Summary: [mqtt] Stop sending a keep-alive if the connection
is closed for a previously unacked keep-alive
Project: lwIP - A Lightweight TCP/IP stack
Submitted by: giusloq
Submitted on: Fri 27 Nov 2020 05:38:25 PM UTC
Category: apps
Severity: 3 - Normal
Item Group: Faulty Behaviour
Status: None
Privacy: Public
Assigned to: None
Open/Closed: Open
Discussion Lock: Any
Planned Release: None
lwIP version: git head
_______________________________________________________
Details:
In mqtt_cyclic_timer() I read:
if (client->keep_alive > 0) {
client->server_watchdog++;
/* If reception from server has been idle for 1.5*keep_alive time,
server is considered unresponsive */
if ((client->server_watchdog * MQTT_CYCLIC_TIMER_INTERVAL) >
(client->keep_alive + client->keep_alive / 2)) {
LWIP_DEBUGF(MQTT_DEBUG_WARN, ("mqtt_cyclic_timer: Server incoming
keep-alive timeout\n"));
mqtt_close(client, MQTT_CONNECT_TIMEOUT);
restart_timer = 0;
}
/* If time for a keep alive message to be sent, transmission has been
idle for keep_alive time */
client->cyclic_tick++;
if ((client->cyclic_tick * MQTT_CYCLIC_TIMER_INTERVAL) >=
client->keep_alive) {
LWIP_DEBUGF(MQTT_DEBUG_TRACE, ("mqtt_cyclic_timer: Sending keep-alive
message to server\n"));
if (mqtt_output_check_space(&client->output, 0) != 0) {
mqtt_output_append_fixed_header(&client->output,
MQTT_MSG_TYPE_PINGREQ, 0, 0, 0, 0);
client->cyclic_tick = 0;
}
}
}
If the condition of the first if was true, mqtt_close() has been called. We
can't enqueue a new keep-alive. So I propose to include the second block in an
else statement:
if (client->keep_alive > 0) {
client->server_watchdog++;
/* If reception from server has been idle for 1.5*keep_alive time,
server is considered unresponsive */
if ((client->server_watchdog * MQTT_CYCLIC_TIMER_INTERVAL) >
(client->keep_alive + client->keep_alive / 2)) {
LWIP_DEBUGF(MQTT_DEBUG_WARN, ("mqtt_cyclic_timer: Server incoming
keep-alive timeout\n"));
mqtt_close(client, MQTT_CONNECT_TIMEOUT);
restart_timer = 0;
} else {
/* If time for a keep alive message to be sent, transmission has been
idle for keep_alive time */
client->cyclic_tick++;
if ((client->cyclic_tick * MQTT_CYCLIC_TIMER_INTERVAL) >=
client->keep_alive) {
LWIP_DEBUGF(MQTT_DEBUG_TRACE, ("mqtt_cyclic_timer: Sending
keep-alive message to server\n"));
if (mqtt_output_check_space(&client->output, 0) != 0) {
mqtt_output_append_fixed_header(&client->output,
MQTT_MSG_TYPE_PINGREQ, 0, 0, 0, 0);
client->cyclic_tick = 0;
}
}
}
}
_______________________________________________________
Reply to this item at:
<https://savannah.nongnu.org/bugs/?59561>
_______________________________________________
Message sent via Savannah
https://savannah.nongnu.org/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lwip-devel] [bug #59561] [mqtt] Stop sending a keep-alive if the connection is closed for a previously unacked keep-alive,
Giuseppe Modugno <=