Merge pull request #237 from chme/threadnames

Set thread names
This commit is contained in:
ejurgensen 2016-03-12 17:18:34 +01:00
commit abce1d0eeb
7 changed files with 59 additions and 6 deletions

View File

@ -30,6 +30,9 @@
#include <time.h>
#include <string.h>
#include <pthread.h>
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
# include <pthread_np.h>
#endif
#include <event2/event.h>
@ -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:

View File

@ -47,6 +47,7 @@
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
# include <sys/time.h>
# include <sys/event.h>
# include <pthread_np.h>
#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:

View File

@ -28,6 +28,9 @@
#include <limits.h>
#include <errno.h>
#include <pthread.h>
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
# include <pthread_np.h>
#endif
#include <time.h>
#include <sys/param.h>
#include <sys/queue.h>
@ -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:

View File

@ -47,6 +47,7 @@
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
# include <netinet/in.h>
# include <pthread_np.h>
#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);

View File

@ -36,6 +36,7 @@
# include <sys/timerfd.h>
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
# include <signal.h>
# include <pthread_np.h>
#endif
#include <event2/event.h>
@ -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;

View File

@ -37,6 +37,9 @@
#include <sys/queue.h>
#include <time.h>
#include <pthread.h>
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
# include <pthread_np.h>
#endif
#include <dlfcn.h>
#include <libspotify/api.h>
@ -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;

View File

@ -30,6 +30,9 @@
#include <string.h>
#include <errno.h>
#include <pthread.h>
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
# include <pthread_np.h>
#endif
#include <event2/event.h>
@ -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: