Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
tvhthread_create: use more nice names
  • Loading branch information
perexg committed Oct 16, 2015
1 parent d7456e7 commit fd28ba6
Show file tree
Hide file tree
Showing 30 changed files with 37 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/avahi.c
Expand Up @@ -303,7 +303,7 @@ pthread_t avahi_tid;
void
avahi_init(void)
{
tvhthread_create(&avahi_tid, NULL, avahi_thread, NULL);
tvhthread_create(&avahi_tid, NULL, avahi_thread, NULL, "avahi");
}

void
Expand Down
2 changes: 1 addition & 1 deletion src/dbus.c
Expand Up @@ -458,7 +458,7 @@ void
dbus_server_start(void)
{
if (dbus_pipe.wr > 0)
tvhthread_create(&dbus_tid, NULL, dbus_server_thread, NULL);
tvhthread_create(&dbus_tid, NULL, dbus_server_thread, NULL, "dbus");
}

void
Expand Down
2 changes: 1 addition & 1 deletion src/descrambler/capmt.c
Expand Up @@ -2168,7 +2168,7 @@ capmt_conf_changed(caclient_t *cac)
if (!capmt->capmt_running) {
capmt->capmt_running = 1;
capmt->capmt_reconfigure = 0;
tvhthread_create(&capmt->capmt_tid, NULL, capmt_thread, capmt);
tvhthread_create(&capmt->capmt_tid, NULL, capmt_thread, capmt, "capmt");
return;
}
pthread_mutex_lock(&capmt->capmt_mutex);
Expand Down
4 changes: 2 additions & 2 deletions src/descrambler/cwc.c
Expand Up @@ -1082,7 +1082,7 @@ cwc_session(cwc_t *cwc)
pthread_cond_init(&cwc->cwc_writer_cond, NULL);
pthread_mutex_init(&cwc->cwc_writer_mutex, NULL);
TAILQ_INIT(&cwc->cwc_writeq);
tvhthread_create(&writer_thread_id, NULL, cwc_writer_thread, cwc);
tvhthread_create(&writer_thread_id, NULL, cwc_writer_thread, cwc, "cwc-writer");

/**
* Mainloop
Expand Down Expand Up @@ -1654,7 +1654,7 @@ cwc_conf_changed(caclient_t *cac)
}
if (!cwc->cwc_running) {
cwc->cwc_running = 1;
tvhthread_create(&cwc->cwc_tid, NULL, cwc_thread, cwc);
tvhthread_create(&cwc->cwc_tid, NULL, cwc_thread, cwc, "cwc");
return;
}
pthread_mutex_lock(&cwc->cwc_mutex);
Expand Down
2 changes: 1 addition & 1 deletion src/dvr/dvr_inotify.c
Expand Up @@ -70,7 +70,7 @@ void dvr_inotify_init ( void )
return;
}

tvhthread_create(&dvr_inotify_tid, NULL, _dvr_inotify_thread, NULL);
tvhthread_create(&dvr_inotify_tid, NULL, _dvr_inotify_thread, NULL, "dvr-inotify");
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/dvr/dvr_rec.c
Expand Up @@ -149,7 +149,7 @@ dvr_rec_subscribe(dvr_entry_t *de)
de->de_chain = prch;

de->de_thread_shutdown = 0;
tvhthread_create(&de->de_thread, NULL, dvr_thread, de);
tvhthread_create(&de->de_thread, NULL, dvr_thread, de, "dvr");
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion src/epggrab.c
Expand Up @@ -370,7 +370,7 @@ void epggrab_init ( void )

/* Start internal grab thread */
epggrab_running = 1;
tvhthread_create(&epggrab_tid, NULL, _epggrab_internal_thread, NULL);
tvhthread_create(&epggrab_tid, NULL, _epggrab_internal_thread, NULL, "epggrabi");
}

/*
Expand Down
2 changes: 1 addition & 1 deletion src/epggrab/module.c
Expand Up @@ -583,7 +583,7 @@ epggrab_module_activate_socket ( void *m, int a )
tvhlog(LOG_DEBUG, mod->id, "starting socket thread");
pthread_attr_init(&tattr);
mod->active = 1;
tvhthread_create(&mod->tid, &tattr, _epggrab_socket_thread, mod);
tvhthread_create(&mod->tid, &tattr, _epggrab_socket_thread, mod, "epggrabso");
}
return 1;
}
Expand Down
2 changes: 1 addition & 1 deletion src/fsmonitor.c
Expand Up @@ -106,7 +106,7 @@ fsmonitor_init ( void )
{
/* Intialise inotify */
fsmonitor_fd = inotify_init1(IN_CLOEXEC);
tvhthread_create0(&fsmonitor_tid, NULL, fsmonitor_thread, NULL, "fsmonitor");
tvhthread_create(&fsmonitor_tid, NULL, fsmonitor_thread, NULL, "fsmonitor");
}

/*
Expand Down
2 changes: 1 addition & 1 deletion src/htsp_server.c
Expand Up @@ -2935,7 +2935,7 @@ htsp_serve(int fd, void **opaque, struct sockaddr_storage *source,
pthread_mutex_unlock(&global_lock);

tvhthread_create(&htsp.htsp_writer_thread, NULL,
htsp_write_scheduler, &htsp);
htsp_write_scheduler, &htsp, "htsp-write");

/**
* Reader loop
Expand Down
2 changes: 1 addition & 1 deletion src/httpc.c
Expand Up @@ -1501,7 +1501,7 @@ http_client_init ( const char *user_agent )

/* Setup thread */
http_running = 1;
tvhthread_create(&http_client_tid, NULL, http_client_thread, NULL);
tvhthread_create(&http_client_tid, NULL, http_client_thread, NULL, "httpc");
#if HTTPCLIENT_TESTSUITE
http_client_testsuite_run();
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/imagecache.c
Expand Up @@ -445,7 +445,7 @@ imagecache_init ( void )

/* Start threads */
#if ENABLE_IMAGECACHE
tvhthread_create(&imagecache_tid, NULL, imagecache_thread, NULL);
tvhthread_create(&imagecache_tid, NULL, imagecache_thread, NULL, "imagecache");

/* Re-try timer */
// TODO: this could be more efficient by being targetted, however
Expand Down
2 changes: 1 addition & 1 deletion src/input/mpegts/iptv/iptv.c
Expand Up @@ -896,7 +896,7 @@ void iptv_init ( void )
/* Setup TS thread */
iptv_poll = tvhpoll_create(10);
pthread_mutex_init(&iptv_lock, NULL);
tvhthread_create(&iptv_thread, NULL, iptv_input_thread, NULL);
tvhthread_create(&iptv_thread, NULL, iptv_input_thread, NULL, "iptv");
}

void iptv_done ( void )
Expand Down
2 changes: 1 addition & 1 deletion src/input/mpegts/linuxdvb/linuxdvb_frontend.c
Expand Up @@ -675,7 +675,7 @@ linuxdvb_frontend_monitor ( void *aux )
tvh_pipe(O_NONBLOCK, &lfe->lfe_dvr_pipe);
pthread_mutex_lock(&lfe->lfe_dvr_lock);
tvhthread_create(&lfe->lfe_dvr_thread, NULL,
linuxdvb_frontend_input_thread, lfe);
linuxdvb_frontend_input_thread, lfe, "lnxdvb-front");
pthread_cond_wait(&lfe->lfe_dvr_cond, &lfe->lfe_dvr_lock);
pthread_mutex_unlock(&lfe->lfe_dvr_lock);

Expand Down
4 changes: 2 additions & 2 deletions src/input/mpegts/mpegts_input.c
Expand Up @@ -1548,9 +1548,9 @@ mpegts_input_thread_start ( mpegts_input_t *mi )
mi->mi_running = 1;

tvhthread_create(&mi->mi_table_tid, NULL,
mpegts_input_table_thread, mi);
mpegts_input_table_thread, mi, "mi-table");
tvhthread_create(&mi->mi_input_tid, NULL,
mpegts_input_thread, mi);
mpegts_input_thread, mi, "mi-main");
}

static void
Expand Down
2 changes: 1 addition & 1 deletion src/input/mpegts/satip/satip_frontend.c
Expand Up @@ -1794,7 +1794,7 @@ satip_frontend_create

tvh_pipe(O_NONBLOCK, &lfe->sf_dvr_pipe);
tvhthread_create(&lfe->sf_dvr_thread, NULL,
satip_frontend_input_thread, lfe);
satip_frontend_input_thread, lfe, "satip-front");

return lfe;
}
Expand Down
2 changes: 1 addition & 1 deletion src/input/mpegts/tsfile/tsfile_input.c
Expand Up @@ -228,7 +228,7 @@ tsfile_input_start_mux ( mpegts_input_t *mi, mpegts_mux_instance_t *t )
return SM_CODE_TUNING_FAILED;
}
tvhtrace("tsfile", "adapter %d starting thread", mi->mi_instance);
tvhthread_create(&ti->ti_thread_id, NULL, tsfile_input_thread, mi);
tvhthread_create(&ti->ti_thread_id, NULL, tsfile_input_thread, mi, "tsfile");
}

/* Current */
Expand Down
2 changes: 1 addition & 1 deletion src/input/mpegts/tvhdhomerun/tvhdhomerun_frontend.c
Expand Up @@ -254,7 +254,7 @@ tvhdhomerun_frontend_monitor_cb( void *aux )
/* start input thread */
tvh_pipe(O_NONBLOCK, &hfe->hf_input_thread_pipe);
pthread_mutex_lock(&hfe->hf_input_thread_mutex);
tvhthread_create(&hfe->hf_input_thread, NULL, tvhdhomerun_frontend_input_thread, hfe);
tvhthread_create(&hfe->hf_input_thread, NULL, tvhdhomerun_frontend_input_thread, hfe, "hdhm-front");
pthread_cond_wait(&hfe->hf_input_thread_cond, &hfe->hf_input_thread_mutex);
pthread_mutex_unlock(&hfe->hf_input_thread_mutex);

Expand Down
2 changes: 1 addition & 1 deletion src/main.c
Expand Up @@ -1001,7 +1001,7 @@ main(int argc, char **argv)

epg_in_load = 1;

tvhthread_create(&tasklet_tid, NULL, tasklet_thread, NULL);
tvhthread_create(&tasklet_tid, NULL, tasklet_thread, NULL, "tasklet");

dbus_server_init(opt_dbus, opt_dbus_session);

Expand Down
2 changes: 1 addition & 1 deletion src/notify.c
Expand Up @@ -127,7 +127,7 @@ void notify_init( void )
notify_queue = NULL;
pthread_mutex_init(&notify_mutex, NULL);
pthread_cond_init(&notify_cond, NULL);
tvhthread_create(&notify_tid, NULL, notify_thread, NULL);
tvhthread_create(&notify_tid, NULL, notify_thread, NULL, "notify");
}

void notify_done( void )
Expand Down
4 changes: 2 additions & 2 deletions src/satip/rtp.c
Expand Up @@ -389,7 +389,7 @@ void satip_rtp_queue(void *id, th_subscription_t *subs,

pthread_mutex_lock(&satip_rtp_lock);
TAILQ_INSERT_TAIL(&satip_rtp_sessions, rtp, link);
tvhthread_create(&rtp->tid, NULL, satip_rtp_thread, rtp);
tvhthread_create(&rtp->tid, NULL, satip_rtp_thread, rtp, "satip-rtp");
pthread_mutex_unlock(&satip_rtp_lock);
}

Expand Down Expand Up @@ -785,7 +785,7 @@ void satip_rtp_init(void)
pthread_mutex_init(&satip_rtp_lock, NULL);

satip_rtcp_run = 1;
tvhthread_create(&satip_rtcp_tid, NULL, satip_rtcp_thread, NULL);
tvhthread_create(&satip_rtcp_tid, NULL, satip_rtcp_thread, NULL, "satip-rtcp");
}

/*
Expand Down
2 changes: 1 addition & 1 deletion src/service.c
Expand Up @@ -1385,7 +1385,7 @@ service_init(void)
TAILQ_INIT(&service_raw_all);
pthread_mutex_init(&pending_save_mutex, NULL);
pthread_cond_init(&pending_save_cond, NULL);
tvhthread_create(&service_saver_tid, NULL, service_saver, NULL);
tvhthread_create(&service_saver_tid, NULL, service_saver, NULL, "service");
}

void
Expand Down
2 changes: 1 addition & 1 deletion src/service_mapper.c
Expand Up @@ -51,7 +51,7 @@ service_mapper_init ( void )
{
TAILQ_INIT(&service_mapper_queue);
pthread_cond_init(&service_mapper_cond, NULL);
tvhthread_create(&service_mapper_tid, NULL, service_mapper_thread, NULL);
tvhthread_create(&service_mapper_tid, NULL, service_mapper_thread, NULL, "svcmap");
}

void
Expand Down
4 changes: 2 additions & 2 deletions src/tcp.c
Expand Up @@ -706,7 +706,7 @@ tcp_server_loop(void *aux)
pthread_mutex_lock(&global_lock);
LIST_INSERT_HEAD(&tcp_server_active, tsl, alink);
pthread_mutex_unlock(&global_lock);
tvhthread_create(&tsl->tid, NULL, tcp_server_start, tsl);
tvhthread_create(&tsl->tid, NULL, tcp_server_start, tsl, "tcp-start");
}
}
tvhtrace("tcp", "server thread finished");
Expand Down Expand Up @@ -1050,7 +1050,7 @@ tcp_server_init(void)
tvhpoll_add(tcp_server_poll, &ev, 1);

tcp_server_running = 1;
tvhthread_create(&tcp_server_tid, NULL, tcp_server_loop, NULL);
tvhthread_create(&tcp_server_tid, NULL, tcp_server_loop, NULL, "tcp-loop");
}

void
Expand Down
4 changes: 2 additions & 2 deletions src/timeshift.c
Expand Up @@ -407,8 +407,8 @@ streaming_target_t *timeshift_create
/* Initialise input */
streaming_queue_init(&ts->wr_queue, 0, 0);
streaming_target_init(&ts->input, timeshift_input, ts, 0);
tvhthread_create(&ts->wr_thread, NULL, timeshift_writer, ts);
tvhthread_create(&ts->rd_thread, NULL, timeshift_reader, ts);
tvhthread_create(&ts->wr_thread, NULL, timeshift_writer, ts, "tshift-wr");
tvhthread_create(&ts->rd_thread, NULL, timeshift_reader, ts, "tshift-rd");

/* Update index */
timeshift_index++;
Expand Down
2 changes: 1 addition & 1 deletion src/timeshift/timeshift_filemgr.c
Expand Up @@ -410,7 +410,7 @@ void timeshift_filemgr_init ( void )
pthread_cond_init(&timeshift_reaper_cond, NULL);
TAILQ_INIT(&timeshift_reaper_list);
tvhthread_create(&timeshift_reaper_thread, NULL,
timeshift_reaper_callback, NULL);
timeshift_reaper_callback, NULL, "tshift-reap");
}

/*
Expand Down
4 changes: 1 addition & 3 deletions src/tvheadend.h
Expand Up @@ -638,13 +638,11 @@ static inline void mystrset(char **p, const char *s)

void doexit(int x);

int tvhthread_create0
int tvhthread_create
(pthread_t *thread, const pthread_attr_t *attr,
void *(*start_routine) (void *), void *arg,
const char *name);

#define tvhthread_create(a, b, c, d) tvhthread_create0(a, b, c, d, #c)

int tvh_open(const char *pathname, int flags, mode_t mode);

int tvh_socket(int domain, int type, int protocol);
Expand Down
2 changes: 1 addition & 1 deletion src/tvhlog.c
Expand Up @@ -420,7 +420,7 @@ tvhlog_init ( int level, int options, const char *path )
void
tvhlog_start ( void )
{
tvhthread_create(&tvhlog_tid, NULL, tvhlog_thread, NULL);
tvhthread_create(&tvhlog_tid, NULL, tvhlog_thread, NULL, "log");
}

void
Expand Down
2 changes: 1 addition & 1 deletion src/upnp.c
Expand Up @@ -245,7 +245,7 @@ upnp_server_init(const char *bindaddr)
TAILQ_INIT(&upnp_data_write);
TAILQ_INIT(&upnp_services);
upnp_running = 1;
tvhthread_create(&upnp_tid, NULL, upnp_thread, (char *)bindaddr);
tvhthread_create(&upnp_tid, NULL, upnp_thread, (char *)bindaddr, "upnp");
}

void
Expand Down
5 changes: 3 additions & 2 deletions src/wrappers.c
Expand Up @@ -181,13 +181,14 @@ thread_wrapper ( void *p )
}

int
tvhthread_create0
tvhthread_create
(pthread_t *thread, const pthread_attr_t *attr,
void *(*start_routine) (void *), void *arg, const char *name)
{
int r;
struct thread_state *ts = calloc(1, sizeof(struct thread_state));
strncpy(ts->name, name, sizeof(ts->name));
strncpy(ts->name, "tvh:", 4);
strncpy(ts->name+4, name, sizeof(ts->name));
ts->name[sizeof(ts->name)-1] = '\0';
ts->run = start_routine;
ts->arg = arg;
Expand Down

0 comments on commit fd28ba6

Please sign in to comment.