diff --git a/ChangeLog.txt b/ChangeLog.txt index e2da59c5..ee68e729 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -27,6 +27,7 @@ Client library: connected. Closes #1725. - `mosquitto_loop_start()` now sets a thread name on Linux, FreeBSD, NetBSD, and OpenBSD. Closes #1777. +- Fix `mosquitto_loop_stop()` not stopping on Windows. Closes #1748. Closes #117. 1.6.10 - 2020-05-25 diff --git a/lib/dummypthread.h b/lib/dummypthread.h index 4207f3d6..611a1574 100644 --- a/lib/dummypthread.h +++ b/lib/dummypthread.h @@ -4,6 +4,7 @@ #define pthread_create(A, B, C, D) #define pthread_join(A, B) #define pthread_cancel(A) +#define pthread_testcancel() #define pthread_mutex_init(A, B) #define pthread_mutex_destroy(A) diff --git a/lib/loop.c b/lib/loop.c index 048b8211..f7b26a0f 100644 --- a/lib/loop.c +++ b/lib/loop.c @@ -256,6 +256,7 @@ int mosquitto_loop_forever(struct mosquitto *mosq, int timeout, int max_packets) while(run){ do{ + pthread_testcancel(); rc = mosquitto_loop(mosq, timeout, max_packets); }while(run && rc == MOSQ_ERR_SUCCESS); /* Quit after fatal errors. */ @@ -280,6 +281,7 @@ int mosquitto_loop_forever(struct mosquitto *mosq, int timeout, int max_packets) return rc; } do{ + pthread_testcancel(); rc = MOSQ_ERR_SUCCESS; state = mosquitto__get_state(mosq); if(state == mosq_cs_disconnecting || state == mosq_cs_disconnected){