mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-05 22:29:49 +00:00
mqtt: Check conn_state before create request for sub_unsub
This also avoid a request leak in client->conn_state == TCP_DISCONNECTED error path. Signed-off-by: Axel Lin <axel.lin@ingics.com>
This commit is contained in:
parent
876720593b
commit
d5bc856f45
@ -1137,15 +1137,14 @@ mqtt_sub_unsub(mqtt_client_t *client, const char *topic, u8_t qos, mqtt_request_
|
||||
LWIP_ERROR("mqtt_publish: total length overflow", (total_len <= 0xFFFF), return ERR_ARG);
|
||||
remaining_length = (u16_t)total_len;
|
||||
|
||||
pkt_id = msg_generate_packet_id(client);
|
||||
r = mqtt_create_request(client->req_list, pkt_id, cb, arg);
|
||||
|
||||
LWIP_ASSERT("mqtt_sub_unsub: qos < 3", qos < 3);
|
||||
if(client->conn_state == TCP_DISCONNECTED) {
|
||||
LWIP_DEBUGF(MQTT_DEBUG_WARN,("mqtt_sub_unsub: Can not (un)subscribe in disconnected state\n"));
|
||||
return ERR_CONN;
|
||||
}
|
||||
|
||||
pkt_id = msg_generate_packet_id(client);
|
||||
r = mqtt_create_request(client->req_list, pkt_id, cb, arg);
|
||||
if(r == NULL) {
|
||||
return ERR_MEM;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user