From 0d1837ebe31d8ed4073fec6f0eb8a08d4cf7516c Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Tue, 24 Aug 2021 11:51:38 +0100 Subject: [PATCH] Deconfigure thread mode when the loop thread ends. Threaded mode is deconfigured when the mosquitto_loop_start() thread ends, which allows mosquitto_loop_start() to be called again. Closes #2242. Thanks to Timo Lange. --- ChangeLog.txt | 2 ++ lib/thread_mosq.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index f60ec06e..afc8235c 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -37,6 +37,8 @@ Client library: connect successfully without verifying certificates, because they were not configured. - Disable TLS v1.3 when using TLS-PSK, because it isn't correctly configured. +- Threaded mode is deconfigured when the mosquitto_loop_start() thread ends, + which allows mosquitto_loop_start() to be called again. Closes #2242. Clients: - mosquitto_sub and mosquitto_rr now open stdout in binary mode on Windows diff --git a/lib/thread_mosq.c b/lib/thread_mosq.c index dbbda85e..32a3e7e0 100644 --- a/lib/thread_mosq.c +++ b/lib/thread_mosq.c @@ -129,6 +129,9 @@ void *mosquitto__thread_main(void *obj) /* Sleep for our keepalive value. publish() etc. will wake us up. */ mosquitto_loop_forever(mosq, mosq->keepalive*1000, 1); } + if(mosq->threaded == mosq_ts_self){ + mosq->threaded = mosq_ts_none; + } return obj; }