diff --git a/src/avahi.c b/src/avahi.c index 662957eb..5a1bb687 100644 --- a/src/avahi.c +++ b/src/avahi.c @@ -280,7 +280,7 @@ void avahi_init(void) { avahi_asp = avahi_simple_poll_new(); - tvhthread_create(&avahi_tid, NULL, avahi_thread, NULL, 0); + tvhthread_create(&avahi_tid, NULL, avahi_thread, NULL); } void diff --git a/src/descrambler/capmt.c b/src/descrambler/capmt.c index 64cd7a20..7a6fec7d 100644 --- a/src/descrambler/capmt.c +++ b/src/descrambler/capmt.c @@ -1917,7 +1917,7 @@ capmt_entry_find(const char *id, int create) tvh_pipe(O_NONBLOCK, &capmt->capmt_pipe); - tvhthread_create(&capmt->capmt_tid, NULL, capmt_thread, capmt, 0); + tvhthread_create(&capmt->capmt_tid, NULL, capmt_thread, capmt); return capmt; } diff --git a/src/descrambler/cwc.c b/src/descrambler/cwc.c index a4ff0065..36d70cea 100755 --- a/src/descrambler/cwc.c +++ b/src/descrambler/cwc.c @@ -1096,7 +1096,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, 0); + tvhthread_create(&writer_thread_id, NULL, cwc_writer_thread, cwc); /** * Mainloop @@ -2127,7 +2127,7 @@ cwc_entry_find(const char *id, int create) cwc->cwc_running = 1; TAILQ_INSERT_TAIL(&cwcs, cwc, cwc_link); - tvhthread_create(&cwc->cwc_tid, NULL, cwc_thread, cwc, 0); + tvhthread_create(&cwc->cwc_tid, NULL, cwc_thread, cwc); return cwc; } diff --git a/src/dvr/dvr_inotify.c b/src/dvr/dvr_inotify.c index 15c80e6b..ba439f96 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, 0); + tvhthread_create(&dvr_inotify_tid, NULL, _dvr_inotify_thread, NULL); } /** diff --git a/src/dvr/dvr_rec.c b/src/dvr/dvr_rec.c index 6bbd4640..d655a77f 100644 --- a/src/dvr/dvr_rec.c +++ b/src/dvr/dvr_rec.c @@ -92,7 +92,7 @@ dvr_rec_subscribe(dvr_entry_t *de) buf, st, flags, NULL, NULL, NULL); - tvhthread_create(&de->de_thread, NULL, dvr_thread, de, 0); + tvhthread_create(&de->de_thread, NULL, dvr_thread, de); } /** diff --git a/src/epggrab.c b/src/epggrab.c index 1501d113..0c802620 100644 --- a/src/epggrab.c +++ b/src/epggrab.c @@ -385,7 +385,7 @@ void epggrab_init ( void ) /* Start internal grab thread */ epggrab_running = 1; - tvhthread_create(&epggrab_tid, NULL, _epggrab_internal_thread, NULL, 0); + tvhthread_create(&epggrab_tid, NULL, _epggrab_internal_thread, NULL); } /* diff --git a/src/epggrab/module.c b/src/epggrab/module.c index b191f1a4..80f6f96a 100644 --- a/src/epggrab/module.c +++ b/src/epggrab/module.c @@ -435,7 +435,7 @@ epggrab_module_enable_socket ( void *m, uint8_t e ) tvhlog(LOG_DEBUG, mod->id, "starting socket thread"); pthread_attr_init(&tattr); mod->enabled = 1; - tvhthread_create(&mod->tid, &tattr, _epggrab_socket_thread, mod, 0); + tvhthread_create(&mod->tid, &tattr, _epggrab_socket_thread, mod); } return 1; } diff --git a/src/fsmonitor.c b/src/fsmonitor.c index 14148cc5..3a9ed30e 100644 --- a/src/fsmonitor.c +++ b/src/fsmonitor.c @@ -104,7 +104,7 @@ fsmonitor_init ( void ) { /* Intialise inotify */ fsmonitor_fd = inotify_init(); - tvhthread_create0(&fsmonitor_tid, NULL, fsmonitor_thread, NULL, "fsmonitor", 0); + tvhthread_create0(&fsmonitor_tid, NULL, fsmonitor_thread, NULL, "fsmonitor"); } /* diff --git a/src/htsp_server.c b/src/htsp_server.c index 6b47911b..f9568541 100644 --- a/src/htsp_server.c +++ b/src/htsp_server.c @@ -2214,7 +2214,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, 0); + htsp_write_scheduler, &htsp); /** * Reader loop diff --git a/src/httpc.c b/src/httpc.c index 728f120e..93e5c1cc 100644 --- a/src/httpc.c +++ b/src/httpc.c @@ -1377,7 +1377,7 @@ http_client_init ( const char *user_agent ) /* Setup thread */ http_running = 1; - tvhthread_create(&http_client_tid, NULL, http_client_thread, NULL, 0); + tvhthread_create(&http_client_tid, NULL, http_client_thread, NULL); #if HTTPCLIENT_TESTSUITE http_client_testsuite_run(); #endif diff --git a/src/idnode.c b/src/idnode.c index 907b5f6c..062b4b69 100644 --- a/src/idnode.c +++ b/src/idnode.c @@ -73,7 +73,7 @@ idnode_init(void) idnode_queue = NULL; pthread_mutex_init(&idnode_mutex, NULL); pthread_cond_init(&idnode_cond, NULL); - tvhthread_create(&idnode_tid, NULL, idnode_thread, NULL, 0); + tvhthread_create(&idnode_tid, NULL, idnode_thread, NULL); } void diff --git a/src/imagecache.c b/src/imagecache.c index 040b1e7e..b28a25cb 100644 --- a/src/imagecache.c +++ b/src/imagecache.c @@ -347,7 +347,7 @@ imagecache_init ( void ) /* Start threads */ #if ENABLE_IMAGECACHE - tvhthread_create(&imagecache_tid, NULL, imagecache_thread, NULL, 0); + tvhthread_create(&imagecache_tid, NULL, imagecache_thread, NULL); /* 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 f0d9f8c7..2bcdf205 100644 --- a/src/input/mpegts/iptv/iptv.c +++ b/src/input/mpegts/iptv/iptv.c @@ -552,7 +552,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, 0); + tvhthread_create(&iptv_thread, NULL, iptv_input_thread, NULL); } void iptv_done ( void ) diff --git a/src/input/mpegts/linuxdvb/linuxdvb_frontend.c b/src/input/mpegts/linuxdvb/linuxdvb_frontend.c index 17b8a738..28a9885c 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_frontend.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_frontend.c @@ -508,7 +508,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, 0); + linuxdvb_frontend_input_thread, lfe); 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 47b8f0ec..77f75203 100644 --- a/src/input/mpegts/mpegts_input.c +++ b/src/input/mpegts/mpegts_input.c @@ -872,9 +872,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, 0); + mpegts_input_table_thread, mi); tvhthread_create(&mi->mi_input_tid, NULL, - mpegts_input_thread, mi, 0); + mpegts_input_thread, mi); } static void diff --git a/src/input/mpegts/satip/satip_frontend.c b/src/input/mpegts/satip/satip_frontend.c index 084ce0e8..51f54b7e 100644 --- a/src/input/mpegts/satip/satip_frontend.c +++ b/src/input/mpegts/satip/satip_frontend.c @@ -1287,7 +1287,7 @@ satip_frontend_tune0 tvh_pipe(O_NONBLOCK, &lfe->sf_dvr_pipe); tvhthread_create(&lfe->sf_dvr_thread, NULL, - satip_frontend_input_thread, lfe, 0); + satip_frontend_input_thread, lfe); gtimer_arm_ms(&lfe->sf_monitor_timer, satip_frontend_signal_cb, lfe, 50); diff --git a/src/input/mpegts/tsfile/tsfile_input.c b/src/input/mpegts/tsfile/tsfile_input.c index fa799748..d5e7da84 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, 0); + tvhthread_create(&ti->ti_thread_id, NULL, tsfile_input_thread, mi); } /* Current */ diff --git a/src/service.c b/src/service.c index 0e02d961..62e1a1cd 100644 --- a/src/service.c +++ b/src/service.c @@ -1247,7 +1247,7 @@ service_init(void) TAILQ_INIT(&service_all); pthread_mutex_init(&pending_save_mutex, NULL); pthread_cond_init(&pending_save_cond, NULL); - tvhthread_create(&service_saver_tid, NULL, service_saver, NULL, 0); + tvhthread_create(&service_saver_tid, NULL, service_saver, NULL); } void diff --git a/src/service_mapper.c b/src/service_mapper.c index 5b30f6e2..f8aeb6af 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, 0); + tvhthread_create(&service_mapper_tid, NULL, service_mapper_thread, NULL); } void diff --git a/src/tcp.c b/src/tcp.c index 1440281d..507de356 100644 --- a/src/tcp.c +++ b/src/tcp.c @@ -528,7 +528,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, 0); + tvhthread_create(&tsl->tid, NULL, tcp_server_start, tsl); } } tvhtrace("tcp", "server thread finished"); @@ -692,7 +692,7 @@ tcp_server_init(int opt_ipv6) tvhpoll_add(tcp_server_poll, &ev, 1); tcp_server_running = 1; - tvhthread_create(&tcp_server_tid, NULL, tcp_server_loop, NULL, 0); + tvhthread_create(&tcp_server_tid, NULL, tcp_server_loop, NULL); } void diff --git a/src/timeshift.c b/src/timeshift.c index 216a4d97..ad16c83f 100644 --- a/src/timeshift.c +++ b/src/timeshift.c @@ -278,8 +278,8 @@ streaming_target_t *timeshift_create /* Initialise input */ streaming_queue_init(&ts->wr_queue, 0); streaming_target_init(&ts->input, timeshift_input, ts, 0); - tvhthread_create(&ts->wr_thread, NULL, timeshift_writer, ts, 0); - tvhthread_create(&ts->rd_thread, NULL, timeshift_reader, ts, 0); + tvhthread_create(&ts->wr_thread, NULL, timeshift_writer, ts); + tvhthread_create(&ts->rd_thread, NULL, timeshift_reader, ts); /* Update index */ timeshift_index++; diff --git a/src/timeshift/timeshift_filemgr.c b/src/timeshift/timeshift_filemgr.c index 19f19bb7..a95953c6 100644 --- a/src/timeshift/timeshift_filemgr.c +++ b/src/timeshift/timeshift_filemgr.c @@ -349,7 +349,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, 1); + timeshift_reaper_callback, NULL); } /* diff --git a/src/tvheadend.h b/src/tvheadend.h index 614fabbb..7d62a0e7 100644 --- a/src/tvheadend.h +++ b/src/tvheadend.h @@ -576,9 +576,9 @@ void doexit(int x); int tvhthread_create0 (pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg, - const char *name, int detach); + const char *name); -#define tvhthread_create(a, b, c, d, e) tvhthread_create0(a, b, c, d, #c, e) +#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); diff --git a/src/tvhlog.c b/src/tvhlog.c index 343e9909..6cd98286 100644 --- a/src/tvhlog.c +++ b/src/tvhlog.c @@ -423,7 +423,7 @@ void tvhlog_start ( void ) { tvhlog_run = 1; - tvhthread_create(&tvhlog_tid, NULL, tvhlog_thread, NULL, 0); + tvhthread_create(&tvhlog_tid, NULL, tvhlog_thread, NULL); } void diff --git a/src/upnp.c b/src/upnp.c index 0c6f5ee8..8ff4e567 100644 --- a/src/upnp.c +++ b/src/upnp.c @@ -197,7 +197,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, 0); + tvhthread_create(&upnp_tid, NULL, upnp_thread, (char *)bindaddr); } void diff --git a/src/wrappers.c b/src/wrappers.c index 23826cd2..41c28c9f 100644 --- a/src/wrappers.c +++ b/src/wrappers.c @@ -131,8 +131,7 @@ thread_wrapper ( void *p ) int tvhthread_create0 (pthread_t *thread, const pthread_attr_t *attr, - void *(*start_routine) (void *), void *arg, const char *name, - int detach) + void *(*start_routine) (void *), void *arg, const char *name) { int r; struct thread_state *ts = calloc(1, sizeof(struct thread_state)); @@ -140,8 +139,6 @@ tvhthread_create0 ts->run = start_routine; ts->arg = arg; r = pthread_create(thread, attr, thread_wrapper, ts); - if (detach) - pthread_detach(*thread); return r; }