Browse Source

TT#111051 set thread specific process names

Change-Id: I6a5bb14c070d93b865510786f5107220b93faef1
pull/1194/head
Richard Fuchs 5 years ago
parent
commit
a8013ffe70
5 changed files with 31 additions and 20 deletions
  1. +9
    -3
      daemon/aux.c
  2. +1
    -1
      daemon/call.c
  3. +17
    -12
      daemon/main.c
  4. +1
    -1
      daemon/websocket.c
  5. +3
    -3
      include/aux.h

+ 9
- 3
daemon/aux.c View File

@ -213,7 +213,7 @@ static void *thread_detach_func(void *d) {
return NULL;
}
static int thread_create(void *(*func)(void *), void *arg, int joinable, pthread_t *handle) {
static int thread_create(void *(*func)(void *), void *arg, int joinable, pthread_t *handle, const char *name) {
pthread_attr_t att;
pthread_t thr;
int ret;
@ -235,11 +235,17 @@ static int thread_create(void *(*func)(void *), void *arg, int joinable, pthread
return ret;
if (handle)
*handle = thr;
#ifdef __GLIBC__
if (name)
pthread_setname_np(thr, name);
#endif
return 0;
}
void thread_create_detach_prio(void (*f)(void *), void *d, const char *scheduler, int priority) {
void thread_create_detach_prio(void (*f)(void *), void *d, const char *scheduler, int priority,
const char *name)
{
struct detach_thread *dt;
dt = g_slice_alloc(sizeof(*dt));
@ -248,7 +254,7 @@ void thread_create_detach_prio(void (*f)(void *), void *d, const char *scheduler
dt->scheduler = scheduler;
dt->priority = priority;
if (thread_create(thread_detach_func, dt, 1, NULL))
if (thread_create(thread_detach_func, dt, 1, NULL, name))
abort();
}


+ 1
- 1
daemon/call.c View File

@ -478,7 +478,7 @@ destroy:
if (xh)
thread_create_detach_prio(xmlrpc_kill_calls, xh, rtpe_config.idle_scheduling,
rtpe_config.idle_priority);
rtpe_config.idle_priority, "XMLRPC callback");
}


+ 17
- 12
daemon/main.c View File

@ -1059,39 +1059,44 @@ int main(int argc, char **argv) {
ilog(LOG_INFO, "Startup complete, version %s", RTPENGINE_VERSION);
thread_create_detach(sighandler, NULL);
thread_create_detach_prio(poller_timer_loop, rtpe_poller, rtpe_config.idle_scheduling, rtpe_config.idle_priority);
thread_create_detach_prio(load_thread, NULL, rtpe_config.idle_scheduling, rtpe_config.idle_priority);
thread_create_detach(sighandler, NULL, "signal handler");
thread_create_detach_prio(poller_timer_loop, rtpe_poller, rtpe_config.idle_scheduling,
rtpe_config.idle_priority, "poller timer");
thread_create_detach_prio(load_thread, NULL, rtpe_config.idle_scheduling, rtpe_config.idle_priority, "load monitor");
if (!is_addr_unspecified(&rtpe_config.redis_ep.address) && initial_rtpe_config.redis_delete_async)
thread_create_detach(redis_delete_async_loop, NULL);
thread_create_detach(redis_delete_async_loop, NULL, "redis async");
if (!is_addr_unspecified(&rtpe_config.redis_ep.address) && rtpe_redis_notify)
thread_create_detach(redis_notify_loop, NULL);
thread_create_detach(redis_notify_loop, NULL, "redis notify");
if (!is_addr_unspecified(&rtpe_config.graphite_ep.address))
thread_create_detach(graphite_loop, NULL);
thread_create_detach(graphite_loop, NULL, "graphite");
thread_create_detach(ice_thread_run, NULL);
thread_create_detach(ice_thread_run, NULL, "ICE");
websocket_start();
service_notify("READY=1\n");
for (idx = 0; idx < rtpe_config.num_threads; ++idx)
thread_create_detach_prio(poller_loop, rtpe_poller, rtpe_config.scheduling, rtpe_config.priority);
thread_create_detach_prio(poller_loop, rtpe_poller, rtpe_config.scheduling,
rtpe_config.priority, "poller");
if (rtpe_config.media_num_threads < 0)
rtpe_config.media_num_threads = rtpe_config.num_threads;
for (idx = 0; idx < rtpe_config.media_num_threads; ++idx) {
#ifdef WITH_TRANSCODING
thread_create_detach_prio(media_player_loop, NULL, rtpe_config.scheduling, rtpe_config.priority);
thread_create_detach_prio(media_player_loop, NULL, rtpe_config.scheduling,
rtpe_config.priority, "media player");
#endif
thread_create_detach_prio(send_timer_loop, NULL, rtpe_config.scheduling, rtpe_config.priority);
thread_create_detach_prio(send_timer_loop, NULL, rtpe_config.scheduling,
rtpe_config.priority, "send timer");
if (rtpe_config.jb_length > 0)
thread_create_detach_prio(jitter_buffer_loop, NULL, rtpe_config.scheduling,
rtpe_config.priority);
thread_create_detach_prio(codec_timers_loop, NULL, rtpe_config.scheduling, rtpe_config.priority);
rtpe_config.priority, "jitter buffer");
thread_create_detach_prio(codec_timers_loop, NULL, rtpe_config.scheduling,
rtpe_config.priority, "codec timer");
}


+ 1
- 1
daemon/websocket.c View File

@ -953,5 +953,5 @@ static void websocket_loop(void *p) {
void websocket_start(void) {
if (!websocket_context)
return;
thread_create_detach_prio(websocket_loop, NULL, rtpe_config.scheduling, rtpe_config.priority);
thread_create_detach_prio(websocket_loop, NULL, rtpe_config.scheduling, rtpe_config.priority, "websocket");
}

+ 3
- 3
include/aux.h View File

@ -278,9 +278,9 @@ taint_func(srandom, "use RAND_seed() instead");
/*** THREAD HELPERS ***/
void threads_join_all(int);
void thread_create_detach_prio(void (*)(void *), void *, const char *, int);
INLINE void thread_create_detach(void (*f)(void *), void *a) {
thread_create_detach_prio(f, a, NULL, 0);
void thread_create_detach_prio(void (*)(void *), void *, const char *, int, const char *);
INLINE void thread_create_detach(void (*f)(void *), void *a, const char *name) {
thread_create_detach_prio(f, a, NULL, 0, name);
}


Loading…
Cancel
Save