mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-27 23:55:57 -05:00
[misc] Centralize thread naming plus name websocket thread
This commit is contained in:
parent
eae09039d5
commit
d2f4efa1bf
@ -30,9 +30,6 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#ifdef HAVE_PTHREAD_NP_H
|
|
||||||
# include <pthread_np.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <event2/event.h>
|
#include <event2/event.h>
|
||||||
#include <sqlite3.h>
|
#include <sqlite3.h>
|
||||||
@ -1640,11 +1637,7 @@ cache_init(void)
|
|||||||
goto thread_fail;
|
goto thread_fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_PTHREAD_SETNAME_NP)
|
thread_setname(tid_cache, "cache");
|
||||||
pthread_setname_np(tid_cache, "cache");
|
|
||||||
#elif defined(HAVE_PTHREAD_SET_NAME_NP)
|
|
||||||
pthread_set_name_np(tid_cache, "cache");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -28,9 +28,6 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#ifdef HAVE_PTHREAD_NP_H
|
|
||||||
# include <pthread_np.h>
|
|
||||||
#endif
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/queue.h>
|
#include <sys/queue.h>
|
||||||
@ -1789,11 +1786,7 @@ httpd_init(const char *webroot)
|
|||||||
goto thread_fail;
|
goto thread_fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_PTHREAD_SETNAME_NP)
|
thread_setname(tid_httpd, "httpd");
|
||||||
pthread_setname_np(tid_httpd, "httpd");
|
|
||||||
#elif defined(HAVE_PTHREAD_SET_NAME_NP)
|
|
||||||
pthread_set_name_np(tid_httpd, "httpd");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -32,9 +32,6 @@
|
|||||||
#include <event2/event.h>
|
#include <event2/event.h>
|
||||||
#include <event2/buffer.h>
|
#include <event2/buffer.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#ifdef HAVE_PTHREAD_NP_H
|
|
||||||
# include <pthread_np.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
@ -927,11 +924,7 @@ input_init(void)
|
|||||||
goto thread_fail;
|
goto thread_fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_PTHREAD_SETNAME_NP)
|
thread_setname(tid_input, "input");
|
||||||
pthread_setname_np(tid_input, "input");
|
|
||||||
#elif defined(HAVE_PTHREAD_SET_NAME_NP)
|
|
||||||
pthread_set_name_np(tid_input, "input");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -35,9 +35,6 @@
|
|||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/queue.h>
|
#include <sys/queue.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#ifdef HAVE_PTHREAD_NP_H
|
|
||||||
# include <pthread_np.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#include <libspotify/api.h>
|
#include <libspotify/api.h>
|
||||||
@ -1575,11 +1572,7 @@ libspotify_init(void)
|
|||||||
goto thread_fail;
|
goto thread_fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_PTHREAD_SETNAME_NP)
|
thread_setname(tid_spotify, "spotify");
|
||||||
pthread_setname_np(tid_spotify, "spotify");
|
|
||||||
#elif defined(HAVE_PTHREAD_SET_NAME_NP)
|
|
||||||
pthread_set_name_np(tid_spotify, "spotify");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
DPRINTF(E_DBG, L_SPOTIFY, "Spotify init complete\n");
|
DPRINTF(E_DBG, L_SPOTIFY, "Spotify init complete\n");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -45,9 +45,6 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#ifdef HAVE_PTHREAD_NP_H
|
|
||||||
# include <pthread_np.h>
|
|
||||||
#endif
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
@ -854,11 +851,7 @@ pipe_thread_start(void)
|
|||||||
CHECK_NULL(L_PLAYER, cmdbase = commands_base_new(evbase_pipe, NULL));
|
CHECK_NULL(L_PLAYER, cmdbase = commands_base_new(evbase_pipe, NULL));
|
||||||
CHECK_ERR(L_PLAYER, pthread_create(&tid_pipe, NULL, pipe_thread_run, NULL));
|
CHECK_ERR(L_PLAYER, pthread_create(&tid_pipe, NULL, pipe_thread_run, NULL));
|
||||||
|
|
||||||
#if defined(HAVE_PTHREAD_SETNAME_NP)
|
thread_setname(tid_pipe, "pipe");
|
||||||
pthread_setname_np(tid_pipe, "pipe");
|
|
||||||
#elif defined(HAVE_PTHREAD_SET_NAME_NP)
|
|
||||||
pthread_set_name_np(tid_pipe, "pipe");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -24,9 +24,6 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#ifdef HAVE_PTHREAD_NP_H
|
|
||||||
# include <pthread_np.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <event2/event.h>
|
#include <event2/event.h>
|
||||||
|
|
||||||
@ -229,11 +226,7 @@ tcp_disconnect(int fd)
|
|||||||
static void
|
static void
|
||||||
thread_name_set(pthread_t thread)
|
thread_name_set(pthread_t thread)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_PTHREAD_SETNAME_NP)
|
thread_setname(thread, "spotify");
|
||||||
pthread_setname_np(thread, "spotify");
|
|
||||||
#elif defined(HAVE_PTHREAD_SET_NAME_NP)
|
|
||||||
pthread_set_name_np(thread, "spotify");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -26,9 +26,6 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#ifdef HAVE_PTHREAD_NP_H
|
|
||||||
# include <pthread_np.h>
|
|
||||||
#endif
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -882,11 +879,7 @@ library_init(void)
|
|||||||
|
|
||||||
CHECK_ERR(L_LIB, pthread_create(&tid_library, NULL, library, NULL));
|
CHECK_ERR(L_LIB, pthread_create(&tid_library, NULL, library, NULL));
|
||||||
|
|
||||||
#if defined(HAVE_PTHREAD_SETNAME_NP)
|
thread_setname(tid_library, "library");
|
||||||
pthread_setname_np(tid_library, "library");
|
|
||||||
#elif defined(HAVE_PTHREAD_SET_NAME_NP)
|
|
||||||
pthread_set_name_np(tid_library, "library");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
13
src/misc.c
13
src/misc.c
@ -44,6 +44,9 @@
|
|||||||
#ifdef HAVE_UUID
|
#ifdef HAVE_UUID
|
||||||
#include <uuid/uuid.h>
|
#include <uuid/uuid.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_PTHREAD_NP_H
|
||||||
|
# include <pthread_np.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
@ -1545,6 +1548,16 @@ mutex_init(pthread_mutex_t *mutex)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
thread_setname(pthread_t thread, const char *name)
|
||||||
|
{
|
||||||
|
#if defined(HAVE_PTHREAD_SETNAME_NP)
|
||||||
|
pthread_setname_np(thread, name);
|
||||||
|
#elif defined(HAVE_PTHREAD_SET_NAME_NP)
|
||||||
|
pthread_set_name_np(thread, name);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_UUID
|
#ifdef HAVE_UUID
|
||||||
void
|
void
|
||||||
uuid_make(char *str)
|
uuid_make(char *str)
|
||||||
|
@ -284,6 +284,10 @@ buildopts_get(void);
|
|||||||
int
|
int
|
||||||
mutex_init(pthread_mutex_t *mutex);
|
mutex_init(pthread_mutex_t *mutex);
|
||||||
|
|
||||||
|
// wrapper for pthread_setname_np/pthread_set_name_np
|
||||||
|
void
|
||||||
|
thread_setname(pthread_t thread, const char *name);
|
||||||
|
|
||||||
void
|
void
|
||||||
uuid_make(char *str);
|
uuid_make(char *str);
|
||||||
|
|
||||||
|
@ -29,9 +29,6 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#ifdef HAVE_PTHREAD_NP_H
|
|
||||||
# include <pthread_np.h>
|
|
||||||
#endif
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/queue.h>
|
#include <sys/queue.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -4846,11 +4843,7 @@ mpd_init(void)
|
|||||||
goto thread_fail;
|
goto thread_fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_PTHREAD_SETNAME_NP)
|
thread_setname(tid_mpd, "mpd");
|
||||||
pthread_setname_np(tid_mpd, "mpd");
|
|
||||||
#elif defined(HAVE_PTHREAD_SET_NAME_NP)
|
|
||||||
pthread_set_name_np(tid_mpd, "mpd");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
mpd_clients = NULL;
|
mpd_clients = NULL;
|
||||||
listener_add(mpd_listener_cb, MPD_ALL_IDLE_LISTENER_EVENTS);
|
listener_add(mpd_listener_cb, MPD_ALL_IDLE_LISTENER_EVENTS);
|
||||||
|
10
src/player.c
10
src/player.c
@ -59,9 +59,6 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#ifdef HAVE_PTHREAD_NP_H
|
|
||||||
# include <pthread_np.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_TIMERFD
|
#ifdef HAVE_TIMERFD
|
||||||
# include <sys/timerfd.h>
|
# include <sys/timerfd.h>
|
||||||
@ -3708,11 +3705,8 @@ player_init(void)
|
|||||||
DPRINTF(E_FATAL, L_PLAYER, "Could not spawn player thread: %s\n", strerror(errno));
|
DPRINTF(E_FATAL, L_PLAYER, "Could not spawn player thread: %s\n", strerror(errno));
|
||||||
goto error_input_deinit;
|
goto error_input_deinit;
|
||||||
}
|
}
|
||||||
#if defined(HAVE_PTHREAD_SETNAME_NP)
|
|
||||||
pthread_setname_np(tid_player, "player");
|
thread_setname(tid_player, "player");
|
||||||
#elif defined(HAVE_PTHREAD_SET_NAME_NP)
|
|
||||||
pthread_set_name_np(tid_player, "player");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -19,12 +19,10 @@
|
|||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include <config.h>
|
# include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <json.h>
|
#include <json.h>
|
||||||
#include <libwebsockets.h>
|
#include <libwebsockets.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#ifdef HAVE_PTHREAD_NP_H
|
|
||||||
# include <pthread_np.h>
|
|
||||||
#endif
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -34,6 +32,7 @@
|
|||||||
#include "conffile.h"
|
#include "conffile.h"
|
||||||
#include "listener.h"
|
#include "listener.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
#include "misc.h"
|
||||||
|
|
||||||
|
|
||||||
static struct lws_context *context;
|
static struct lws_context *context;
|
||||||
@ -523,6 +522,8 @@ websocket_init(void)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
thread_setname(tid_websocket, "websocket");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
src/worker.c
10
src/worker.c
@ -30,9 +30,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#ifdef HAVE_PTHREAD_NP_H
|
|
||||||
# include <pthread_np.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <event2/event.h>
|
#include <event2/event.h>
|
||||||
|
|
||||||
@ -40,6 +37,7 @@
|
|||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "worker.h"
|
#include "worker.h"
|
||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
|
#include "misc.h"
|
||||||
|
|
||||||
|
|
||||||
struct worker_arg
|
struct worker_arg
|
||||||
@ -191,11 +189,7 @@ worker_init(void)
|
|||||||
goto thread_fail;
|
goto thread_fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_PTHREAD_SETNAME_NP)
|
thread_setname(tid_worker, "worker");
|
||||||
pthread_setname_np(tid_worker, "worker");
|
|
||||||
#elif defined(HAVE_PTHREAD_SET_NAME_NP)
|
|
||||||
pthread_set_name_np(tid_worker, "worker");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user