`mosquitto_loop_start()` now sets a thread name.

This applies on Linux, FreeBSD, NetBSD, and OpenBSD.

Closes #1777. Thanks to ABuch19.
pull/1781/head
Roger A. Light 5 years ago
parent ebb0f13f08
commit bd27935ff6

@ -25,6 +25,8 @@ Client library:
- Improved documentation around connect callback return codes. Close #1730. - Improved documentation around connect callback return codes. Close #1730.
- Fix `mosquitto_publish*()` no longer returning `MOSQ_ERR_NO_CONN` when not - Fix `mosquitto_publish*()` no longer returning `MOSQ_ERR_NO_CONN` when not
connected. Closes #1725. connected. Closes #1725.
- `mosquitto_loop_start()` now sets a thread name on Linux, FreeBSD, NetBSD,
and OpenBSD. Closes #1777.
1.6.10 - 2020-05-25 1.6.10 - 2020-05-25

@ -20,6 +20,12 @@ Contributors:
#include <time.h> #include <time.h>
#endif #endif
#if defined(__linux__) || defined(__NetBSD__)
# include <pthread.h>
#elif defined(__FreeBSD__) || defined(__OpenBSD__)
# include <pthread_np.h>
#endif
#include "mosquitto_internal.h" #include "mosquitto_internal.h"
#include "net_mosq.h" #include "net_mosq.h"
#include "util_mosq.h" #include "util_mosq.h"
@ -33,6 +39,13 @@ int mosquitto_loop_start(struct mosquitto *mosq)
mosq->threaded = mosq_ts_self; mosq->threaded = mosq_ts_self;
if(!pthread_create(&mosq->thread_id, NULL, mosquitto__thread_main, mosq)){ if(!pthread_create(&mosq->thread_id, NULL, mosquitto__thread_main, mosq)){
#if defined(__linux__)
pthread_setname_np(mosq->thread_id, "mosquitto loop");
#elif defined(__NetBSD__)
pthread_setname_np(mosq->thread_id, "%s", "mosquitto loop");
#elif defined(__FreeBSD__) || defined(__OpenBSD__)
pthread_set_name_np(mosq->thread_id, "mosquitto loop");
#endif
return MOSQ_ERR_SUCCESS; return MOSQ_ERR_SUCCESS;
}else{ }else{
return MOSQ_ERR_ERRNO; return MOSQ_ERR_ERRNO;

Loading…
Cancel
Save