Skip to content

Commit 7a39502

Browse files
committed
fix mqtt_release fail when called after mqtt_lease
If mqtt_release() is called just after mqtt_lease(), the state is always CLIENT_STATE_INITIALIZED and release fails as it checks for CLIENT_STATE_INVALID. Signed-off-by: Ajay Bhargav <[email protected]>
1 parent 6583189 commit 7a39502

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

mqttclient/mqttclient.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,10 @@ int mqtt_release(mqtt_client_t* c)
12481248
platform_timer_init(&timer);
12491249
platform_timer_cutdown(&timer, c->mqtt_cmd_timeout);
12501250

1251+
/* invalidate state if client is only initialized */
1252+
if (mqtt_get_client_state(c) == CLIENT_STATE_INITIALIZED)
1253+
mqtt_set_client_state(c, CLIENT_STATE_INVALID);
1254+
12511255
/* wait for the clean session to complete */
12521256
while ((CLIENT_STATE_INVALID != mqtt_get_client_state(c))) {
12531257
// platform_timer_usleep(1000); // 1ms avoid compiler optimization.

0 commit comments

Comments
 (0)