diff --git a/src/cache.c b/src/cache.c index 26befb86..895c734b 100644 --- a/src/cache.c +++ b/src/cache.c @@ -30,6 +30,9 @@ #include #include #include +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +# include +#endif #include @@ -1848,6 +1851,12 @@ cache_init(void) goto thread_fail; } +#if defined(__linux__) + pthread_setname_np(tid_cache, "cache"); +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) + pthread_set_name_np(tid_cache, "cache"); +#endif + return 0; thread_fail: diff --git a/src/filescanner.c b/src/filescanner.c index d25958c5..45c961c9 100644 --- a/src/filescanner.c +++ b/src/filescanner.c @@ -47,6 +47,7 @@ #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) # include # include +# include #endif #ifdef HAVE_REGEX_H @@ -2313,6 +2314,12 @@ filescanner_init(void) goto thread_fail; } +#if defined(__linux__) + pthread_setname_np(tid_scan, "filescanner"); +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) + pthread_set_name_np(tid_scan, "filescanner"); +#endif + return 0; thread_fail: diff --git a/src/httpd.c b/src/httpd.c index fe1617cf..5d8773c7 100644 --- a/src/httpd.c +++ b/src/httpd.c @@ -28,6 +28,9 @@ #include #include #include +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +# include +#endif #include #include #include @@ -1394,6 +1397,12 @@ httpd_init(void) goto thread_fail; } +#if defined(__linux__) + pthread_setname_np(tid_httpd, "httpd"); +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) + pthread_set_name_np(tid_httpd, "httpd"); +#endif + return 0; thread_fail: diff --git a/src/mpd.c b/src/mpd.c index c69eace0..b8d09ae4 100644 --- a/src/mpd.c +++ b/src/mpd.c @@ -47,6 +47,7 @@ #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) # include +# include #endif #include "logger.h" @@ -4919,6 +4920,12 @@ int mpd_init(void) goto thread_fail; } +#if defined(__linux__) + pthread_setname_np(tid_mpd, "mpd"); +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) + pthread_set_name_np(tid_mpd, "mpd"); +#endif + idle_clients = NULL; listener_add(mpd_listener_cb, LISTENER_PLAYER | LISTENER_PLAYLIST | LISTENER_VOLUME | LISTENER_SPEAKER | LISTENER_OPTIONS); diff --git a/src/player.c b/src/player.c index fb814864..a1a50d0a 100644 --- a/src/player.c +++ b/src/player.c @@ -36,6 +36,7 @@ # include #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) # include +# include #endif #include @@ -3386,9 +3387,7 @@ playerqueue_add(struct player_command *cmd) queue_shuffle(queue, cur_id); } - //TODO [refactor] Unnecessary if, always set plid to 0 after adding items - if (cur_plid != 0) - cur_plid = 0; + cur_plid = 0; cur_plversion++; listener_notify(LISTENER_PLAYLIST); @@ -3411,9 +3410,7 @@ playerqueue_add_next(struct player_command *cmd) if (shuffle) queue_shuffle(queue, cur_id); - //TODO [refactor] Unnecessary if, always set plid to 0 after adding items - if (cur_plid != 0) - cur_plid = 0; + cur_plid = 0; cur_plversion++; listener_notify(LISTENER_PLAYLIST); @@ -4731,6 +4728,12 @@ player_init(void) DPRINTF(E_FATAL, L_PLAYER, "Could not spawn player thread: %s\n", strerror(errno)); goto thread_fail; } +#if defined(__linux__) + pthread_setname_np(tid_player, "player"); +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) + pthread_set_name_np(tid_player, "player"); +#endif + return 0; diff --git a/src/spotify.c b/src/spotify.c index 0710c179..f412a1ef 100644 --- a/src/spotify.c +++ b/src/spotify.c @@ -37,6 +37,9 @@ #include #include #include +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +# include +#endif #include #include @@ -2296,6 +2299,12 @@ spotify_init(void) goto thread_fail; } +#if defined(__linux__) + pthread_setname_np(tid_spotify, "spotify"); +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) + pthread_set_name_np(tid_spotify, "spotify"); +#endif + DPRINTF(E_DBG, L_SPOTIFY, "Spotify init complete\n"); return 0; diff --git a/src/worker.c b/src/worker.c index a362e507..69b4d1aa 100644 --- a/src/worker.c +++ b/src/worker.c @@ -30,6 +30,9 @@ #include #include #include +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +# include +#endif #include @@ -332,6 +335,12 @@ worker_init(void) goto thread_fail; } +#if defined(__linux__) + pthread_setname_np(tid_worker, "worker"); +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) + pthread_set_name_np(tid_worker, "worker"); +#endif + return 0; thread_fail: