From e5b290ed46047d4c24534205cd15c8d5d52a3041 Mon Sep 17 00:00:00 2001 From: bbergeron Date: Wed, 22 May 2024 00:52:37 -0400 Subject: Remove thread-local & signal-handling code stub Another instance of code I didn't mean to commit and, two months after writing, has lost any sense of purpose or direction. Moreover, I've grown to dislike POSIX signals during that time window so I don't see any reason to keep that code. --- streamer.c | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) (limited to 'streamer.c') diff --git a/streamer.c b/streamer.c index f02efed..7ba83ac 100644 --- a/streamer.c +++ b/streamer.c @@ -1,5 +1,3 @@ -#include -#include #include #include #include @@ -29,16 +27,6 @@ struct Streamer { char *current_song; }; -/* ===== Thread-local storage ===== */ -static pthread_key_t streamer_worker_key; -static pthread_once_t streamer_worker_once = PTHREAD_ONCE_INIT; - -static void streamer_worker_key_create(void) -{ - pthread_key_create(&streamer_worker_key, NULL); -} - - /* ====== Streamer initialisation ===== */ static void *streamer_worker (void *t); @@ -48,8 +36,6 @@ Streamer *streamer_init (const struct StreamerOpt *opts) Playlist *p = NULL; HLSRemuxer *r = NULL; - pthread_once(&streamer_worker_once, streamer_worker_key_create); - if ((s = malloc(sizeof(*s))) == NULL) goto error; if ((p = playlist_init()) == NULL) @@ -148,18 +134,6 @@ void streamer_free (Streamer *s) free(s); } - -static void streamer_worker_sighandler(int sig) -{ - Streamer *streamer; - streamer = pthread_getspecific(streamer_worker_key); - - pthread_mutex_lock(&streamer->state_mutex); - streamer->state = STATE_TERM; - pthread_mutex_unlock(&streamer->state_mutex); -} - - static inline int streamer_worker_conf_priority(void) { errno = 0; @@ -167,38 +141,15 @@ static inline int streamer_worker_conf_priority(void) return errno ? -1 : 0; } -static inline int streamer_worker_conf_sighandling(void) -{ - sigset_t set; - struct sigaction sigact; - - /* Configure SIGTERM interuptor */ - sigact.sa_handler = streamer_worker_sighandler; - sigact.sa_flags = 0; - sigemptyset(&sigact.sa_mask); - sigaction(SIGTERM, &sigact, NULL); // term - sigaction(SIGUSR1, &sigact, NULL); // play/pause - sigaction(SIGUSR2, &sigact, NULL); // skip - - /* Unblock SIGTERM */ - sigemptyset(&set); - sigaddset(&set, SIGTERM); - sigaddset(&set, SIGUSR1); - sigaddset(&set, SIGUSR2); - pthread_sigmask(SIG_UNBLOCK, &set, NULL); -} - static void *streamer_worker(void *arg) { Streamer *s; struct Entry next; - pthread_setspecific(streamer_worker_key, (s = arg)); /* Configure worker */ pthread_mutex_lock(&s->worker_ready_mutex); streamer_worker_conf_priority(); - streamer_worker_conf_sighandling(); s->worker_ready_flag = 1; pthread_cond_broadcast(&s->worker_ready_cond); pthread_mutex_unlock(&s->worker_ready_mutex); -- cgit v1.2.3