From 9a5b67031e1707c0d7e56bab2c7384e518955f48 Mon Sep 17 00:00:00 2001 From: chme Date: Sun, 6 Mar 2016 10:09:34 +0100 Subject: [PATCH 1/2] [player] Remove unnecessary check for plid != 0 and set plid always to 0 if queue changed --- src/player.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/player.c b/src/player.c index 4e6ca08b..0357fc06 100644 --- a/src/player.c +++ b/src/player.c @@ -3386,9 +3386,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 +3409,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); From 98d6db002f5310b5a2d276d7ef7e15235f39cb88 Mon Sep 17 00:00:00 2001 From: chme Date: Sat, 5 Mar 2016 13:19:55 +0100 Subject: [PATCH 2/2] Set thread names to make it easier to identify threads during debugging --- src/cache.c | 9 +++++++++ src/filescanner.c | 7 +++++++ src/httpd.c | 9 +++++++++ src/mpd.c | 7 +++++++ src/player.c | 7 +++++++ src/spotify.c | 9 +++++++++ src/worker.c | 9 +++++++++ 7 files changed, 57 insertions(+) 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 5c8e97ba..1928a7da 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" @@ -4909,6 +4910,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 0357fc06..6863aba0 100644 --- a/src/player.c +++ b/src/player.c @@ -36,6 +36,7 @@ # include #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) # include +# include #endif #include @@ -4727,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 63be5efd..3eb43f6f 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 @@ -2274,6 +2277,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: