Move calls to thread_setname() into the thread start routines and move to a single argument thread_setname()

This commit is contained in:
Brad Keifer
2025-11-09 18:52:35 +11:00
parent 28528abbcd
commit 9c8728f10f
14 changed files with 22 additions and 22 deletions

View File

@@ -1690,6 +1690,7 @@ cache(void *arg)
int ret;
int i;
thread_setname("cache");
ret = cache_open();
if (ret < 0)
{
@@ -2062,7 +2063,6 @@ cache_init(void)
CHECK_NULL(L_CACHE, cmdbase = commands_base_new(evbase_cache, NULL));
CHECK_ERR(L_CACHE, pthread_create(&tid_cache, NULL, cache, NULL));
thread_setname(tid_cache, "cache");
DPRINTF(E_INFO, L_CACHE, "Cache thread init\n");

View File

@@ -46,6 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <event2/thread.h>
#include "evthr.h"
#include "misc.h"
#ifndef TAILQ_FOREACH_SAFE
#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
@@ -135,6 +136,7 @@ _evthr_loop(void *args)
pthread_exit(NULL);
}
thread_setname("evthr");
thread->evbase = event_base_new();
thread->event = event_new(thread->evbase, thread->rdr,
EV_READ | EV_PERSIST, _evthr_read_cmd, args);

View File

@@ -1538,7 +1538,7 @@ thread_init_cb(struct evthr *thr, void *shared)
struct event_base *evbase;
httpd_server *server;
thread_setname(pthread_self(), "httpd");
thread_setname("httpd");
CHECK_ERR(L_HTTPD, db_perthread_init());
CHECK_NULL(L_HTTPD, evbase = evthr_get_base(thr));

View File

@@ -656,6 +656,8 @@ input(void *arg)
{
int ret;
thread_setname("input");
ret = db_perthread_init();
if (ret < 0)
{
@@ -932,8 +934,6 @@ input_init(void)
goto thread_fail;
}
thread_setname(tid_input, "input");
return 0;
thread_fail:

View File

@@ -817,6 +817,7 @@ pipe_watch_update(void *arg, int *retval)
static void *
pipe_thread_run(void *arg)
{
thread_setname("pipe");
event_base_dispatch(evbase_pipe);
pthread_exit(NULL);
@@ -934,8 +935,6 @@ pipe_thread_start(void)
CHECK_NULL(L_PLAYER, evbase_pipe = event_base_new());
CHECK_NULL(L_PLAYER, cmdbase = commands_base_new(evbase_pipe, NULL));
CHECK_ERR(L_PLAYER, pthread_create(&tid_pipe, NULL, pipe_thread_run, NULL));
thread_setname(tid_pipe, "pipe");
}
static void

View File

@@ -240,7 +240,7 @@ tcp_disconnect(int fd)
static void
thread_name_set(pthread_t thread)
{
thread_setname(thread, "spotify");
thread_setname("spotify");
}
static void

View File

@@ -1005,6 +1005,8 @@ library(void *arg)
{
int ret;
thread_setname("library");
#ifdef __linux__
struct sched_param param;
@@ -1074,8 +1076,6 @@ library_init(void)
CHECK_ERR(L_LIB, pthread_create(&tid_library, NULL, library, NULL));
thread_setname(tid_library, "library");
return 0;
}

View File

@@ -1891,7 +1891,7 @@ thread_getnametid(char *buf, size_t len)
}
void
thread_setname(pthread_t thread, const char *name)
thread_setname(const char *name)
{
#if defined(HAVE_PTHREAD_SETNAME_NP_1)
pthread_setname_np(name);
@@ -1900,9 +1900,9 @@ thread_setname(pthread_t thread, const char *name)
__func__, name
);
#elif defined(HAVE_PTHREAD_SETNAME_NP_2)
pthread_setname_np(thread, name);
pthread_setname_np(pthread_self(), name);
#elif defined(HAVE_PTHREAD_SET_NAME_NP)
pthread_set_name_np(thread, name);
pthread_set_name_np(pthread_self(), name);
#endif
}

View File

@@ -331,7 +331,7 @@ thread_getnametid(char *buf, size_t len);
// wrapper for pthread_setname_np/pthread_set_name_np
void
thread_setname(pthread_t thread, const char *name);
thread_setname(const char *name);
void
uuid_make(char *str);

View File

@@ -4242,6 +4242,8 @@ mpd(void *arg)
{
int ret;
thread_setname("mpd");
ret = db_perthread_init();
if (ret < 0)
{
@@ -4370,8 +4372,6 @@ mpd_init(void)
goto thread_fail;
}
thread_setname(tid_mpd, "mpd");
mpd_clients = NULL;
listener_add(mpd_listener_cb, MPD_ALL_IDLE_LISTENER_EVENTS, NULL);

View File

@@ -470,6 +470,8 @@ incoming_cb(int fd, short what, void *arg)
static void *
airplay_events(void *arg)
{
thread_setname("airplay events");
event_base_dispatch(evbase);
pthread_exit(NULL);
@@ -519,8 +521,6 @@ airplay_events_init(void)
goto error;
}
// TODO thread_name_set(thread_id, "airplay events");
return 0;
error:

View File

@@ -3839,6 +3839,8 @@ player(void *arg)
struct output_device *device;
int ret;
thread_setname("player");
ret = db_perthread_init();
if (ret < 0)
{
@@ -3954,8 +3956,6 @@ player_init(void)
goto error_input_deinit;
}
thread_setname(tid_player, "player");
return 0;
error_input_deinit:

View File

@@ -415,6 +415,7 @@ static struct lws_protocols protocols[] =
static void *
websocket(void *arg)
{
thread_setname("websocket");
listener_add(listener_cb, LISTENER_UPDATE | LISTENER_DATABASE | LISTENER_PAIRING | LISTENER_SPOTIFY | LISTENER_LASTFM | LISTENER_SPEAKER
| LISTENER_PLAYER | LISTENER_OPTIONS | LISTENER_VOLUME | LISTENER_QUEUE, NULL);
@@ -533,8 +534,6 @@ websocket_init(void)
return -1;
}
thread_setname(tid_websocket, "websocket");
websocket_is_initialized = true;
return 0;

View File

@@ -100,7 +100,7 @@ init_cb(struct evthr *thr, void *shared)
worker_thr = thr;
thread_setname(pthread_self(), "worker");
thread_setname("worker");
}
static void