From 0276f3e635c391fa7495520f5378d7771b375b51 Mon Sep 17 00:00:00 2001 From: Chunho Lee Date: Tue, 13 Apr 2021 08:23:13 -0700 Subject: [PATCH] ss: mqtt: Avoid CONNECTING to DISCONNECTED transition Check previous states with 'ss_dangling_connected'. If it did not visit CONNECTED, transit to UNREACHABLE instead of DISCONNECTED. --- lib/secure-streams/protocols/ss-mqtt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/secure-streams/protocols/ss-mqtt.c b/lib/secure-streams/protocols/ss-mqtt.c index 7833751e1..a5319028a 100644 --- a/lib/secure-streams/protocols/ss-mqtt.c +++ b/lib/secure-streams/protocols/ss-mqtt.c @@ -69,7 +69,11 @@ secstream_mqtt(struct lws *wsi, enum lws_callback_reasons reason, void *user, lws_sul_cancel(&h->sul_timeout); lws_conmon_ss_json(h); - r= lws_ss_event_helper(h, LWSSSCS_DISCONNECTED); + + if (h->ss_dangling_connected) + r = lws_ss_event_helper(h, LWSSSCS_DISCONNECTED); + else + r = lws_ss_event_helper(h, LWSSSCS_UNREACHABLE); if (h->wsi) lws_set_opaque_user_data(h->wsi, NULL); h->wsi = NULL;