From: Jaroslav Kysela Date: Fri, 16 Oct 2015 19:17:47 +0000 (+0200) Subject: tvhthread_create: use more nice names X-Git-Tag: v4.2.1~1891 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fd28ba61fe4db28ad9307d19b7393d460bfce4c6;p=thirdparty%2Ftvheadend.git tvhthread_create: use more nice names --- diff --git a/src/avahi.c b/src/avahi.c index 2dd1092f4..923986e23 100644 --- a/src/avahi.c +++ b/src/avahi.c @@ -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 diff --git a/src/dbus.c b/src/dbus.c index 4071faec2..b0cdfc220 100644 --- a/src/dbus.c +++ b/src/dbus.c @@ -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 diff --git a/src/descrambler/capmt.c b/src/descrambler/capmt.c index cf3865e48..0286f5938 100644 --- a/src/descrambler/capmt.c +++ b/src/descrambler/capmt.c @@ -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); diff --git a/src/descrambler/cwc.c b/src/descrambler/cwc.c index f722b435c..54c3e07f7 100644 --- a/src/descrambler/cwc.c +++ b/src/descrambler/cwc.c @@ -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 @@ -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); diff --git a/src/dvr/dvr_inotify.c b/src/dvr/dvr_inotify.c index e30e5eace..472d292b5 100644 --- a/src/dvr/dvr_inotify.c +++ b/src/dvr/dvr_inotify.c @@ -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"); } /** diff --git a/src/dvr/dvr_rec.c b/src/dvr/dvr_rec.c index 35c71611e..2fbfe384d 100644 --- a/src/dvr/dvr_rec.c +++ b/src/dvr/dvr_rec.c @@ -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; } diff --git a/src/epggrab.c b/src/epggrab.c index 2db756c68..db13e7320 100644 --- a/src/epggrab.c +++ b/src/epggrab.c @@ -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"); } /* diff --git a/src/epggrab/module.c b/src/epggrab/module.c index 1034beffe..540c3259b 100644 --- a/src/epggrab/module.c +++ b/src/epggrab/module.c @@ -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; } diff --git a/src/fsmonitor.c b/src/fsmonitor.c index a311fcb90..595f6c3af 100644 --- a/src/fsmonitor.c +++ b/src/fsmonitor.c @@ -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"); } /* diff --git a/src/htsp_server.c b/src/htsp_server.c index 92d83890e..99cbd9cc9 100644 --- a/src/htsp_server.c +++ b/src/htsp_server.c @@ -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 diff --git a/src/httpc.c b/src/httpc.c index d92971aaf..56d2b8dbd 100644 --- a/src/httpc.c +++ b/src/httpc.c @@ -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 diff --git a/src/imagecache.c b/src/imagecache.c index c46e7d50c..673378361 100644 --- a/src/imagecache.c +++ b/src/imagecache.c @@ -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 diff --git a/src/input/mpegts/iptv/iptv.c b/src/input/mpegts/iptv/iptv.c index 1d608dda7..5c9521a02 100644 --- a/src/input/mpegts/iptv/iptv.c +++ b/src/input/mpegts/iptv/iptv.c @@ -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 ) diff --git a/src/input/mpegts/linuxdvb/linuxdvb_frontend.c b/src/input/mpegts/linuxdvb/linuxdvb_frontend.c index 10c8deedb..3f66959d7 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_frontend.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_frontend.c @@ -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); diff --git a/src/input/mpegts/mpegts_input.c b/src/input/mpegts/mpegts_input.c index c398ada89..cb7973287 100644 --- a/src/input/mpegts/mpegts_input.c +++ b/src/input/mpegts/mpegts_input.c @@ -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 diff --git a/src/input/mpegts/satip/satip_frontend.c b/src/input/mpegts/satip/satip_frontend.c index efea4799b..a7454606c 100644 --- a/src/input/mpegts/satip/satip_frontend.c +++ b/src/input/mpegts/satip/satip_frontend.c @@ -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; } diff --git a/src/input/mpegts/tsfile/tsfile_input.c b/src/input/mpegts/tsfile/tsfile_input.c index 29dc6cd72..5e8d44edb 100644 --- a/src/input/mpegts/tsfile/tsfile_input.c +++ b/src/input/mpegts/tsfile/tsfile_input.c @@ -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 */ diff --git a/src/input/mpegts/tvhdhomerun/tvhdhomerun_frontend.c b/src/input/mpegts/tvhdhomerun/tvhdhomerun_frontend.c index a845a7645..6ebab7efb 100644 --- a/src/input/mpegts/tvhdhomerun/tvhdhomerun_frontend.c +++ b/src/input/mpegts/tvhdhomerun/tvhdhomerun_frontend.c @@ -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); diff --git a/src/main.c b/src/main.c index d5c410df4..81c7f7bc7 100644 --- a/src/main.c +++ b/src/main.c @@ -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); diff --git a/src/notify.c b/src/notify.c index 77fd2b1ce..b7b8b1a87 100644 --- a/src/notify.c +++ b/src/notify.c @@ -127,7 +127,7 @@ void notify_init( void ) notify_queue = NULL; pthread_mutex_init(¬ify_mutex, NULL); pthread_cond_init(¬ify_cond, NULL); - tvhthread_create(¬ify_tid, NULL, notify_thread, NULL); + tvhthread_create(¬ify_tid, NULL, notify_thread, NULL, "notify"); } void notify_done( void ) diff --git a/src/satip/rtp.c b/src/satip/rtp.c index b9e770efa..5bebac35d 100644 --- a/src/satip/rtp.c +++ b/src/satip/rtp.c @@ -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); } @@ -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"); } /* diff --git a/src/service.c b/src/service.c index b1e13ce84..2acf4e478 100644 --- a/src/service.c +++ b/src/service.c @@ -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 diff --git a/src/service_mapper.c b/src/service_mapper.c index 5a22221ee..3a35cd109 100644 --- a/src/service_mapper.c +++ b/src/service_mapper.c @@ -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 diff --git a/src/tcp.c b/src/tcp.c index 7cba1c550..83666886f 100644 --- a/src/tcp.c +++ b/src/tcp.c @@ -706,7 +706,7 @@ next: 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"); @@ -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 diff --git a/src/timeshift.c b/src/timeshift.c index 3f60d7e46..452e69ea8 100644 --- a/src/timeshift.c +++ b/src/timeshift.c @@ -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++; diff --git a/src/timeshift/timeshift_filemgr.c b/src/timeshift/timeshift_filemgr.c index 0da28b120..48fc358db 100644 --- a/src/timeshift/timeshift_filemgr.c +++ b/src/timeshift/timeshift_filemgr.c @@ -410,7 +410,7 @@ void timeshift_filemgr_init ( void ) pthread_cond_init(×hift_reaper_cond, NULL); TAILQ_INIT(×hift_reaper_list); tvhthread_create(×hift_reaper_thread, NULL, - timeshift_reaper_callback, NULL); + timeshift_reaper_callback, NULL, "tshift-reap"); } /* diff --git a/src/tvheadend.h b/src/tvheadend.h index aa6decac8..c1bbf26b0 100644 --- a/src/tvheadend.h +++ b/src/tvheadend.h @@ -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); diff --git a/src/tvhlog.c b/src/tvhlog.c index f2bbfc629..5af7bce2d 100644 --- a/src/tvhlog.c +++ b/src/tvhlog.c @@ -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 diff --git a/src/upnp.c b/src/upnp.c index 137322c7d..bf0c48913 100644 --- a/src/upnp.c +++ b/src/upnp.c @@ -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 diff --git a/src/wrappers.c b/src/wrappers.c index f464e7c43..7d1ab9c89 100644 --- a/src/wrappers.c +++ b/src/wrappers.c @@ -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;