From 8bc1a5b6aedb7373c9d0cced455a3216f82608ac Mon Sep 17 00:00:00 2001 From: "Rob Swindell (on Windows)" <rob@synchro.net> Date: Sat, 27 May 2023 16:40:06 -0700 Subject: [PATCH] mosquitto_loop_stop() can block even when force=true Contrary to https://mosquitto.org/api/files/mosquitto-h.html#mosquitto_loop_stop, passing force=true is not enough for the mosquitto network thread to end, mosquitto_disconnect() must be called. --- src/sbbs3/js_mqtt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sbbs3/js_mqtt.c b/src/sbbs3/js_mqtt.c index 0efc7a7544..cdae1c80e7 100644 --- a/src/sbbs3/js_mqtt.c +++ b/src/sbbs3/js_mqtt.c @@ -40,8 +40,8 @@ static void js_finalize_mqtt(JSContext* cx, JSObject* obj) if((p = (private_t*)JS_GetPrivate(cx,obj)) == NULL) return; - if(p->handle != NULL) { + mosquitto_disconnect(p->handle); mosquitto_loop_stop(p->handle, /* force: */true); mosquitto_destroy(p->handle); } -- GitLab