From: Andre Noll Date: Mon, 30 Dec 2013 23:20:32 +0000 (+0000) Subject: task_register() conversion: signal task X-Git-Tag: v0.5.3~8^2~20 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=82ecf70328a16bedbbb555ca478c7b6b45af9621;p=paraslash.git task_register() conversion: signal task --- diff --git a/afs.c b/afs.c index fa4f4326..a2789bd8 100644 --- a/afs.c +++ b/afs.c @@ -721,7 +721,7 @@ static int open_afs_tables(void) static void signal_pre_select(struct sched *s, struct task *t) { - struct signal_task *st = container_of(t, struct signal_task, task); + struct signal_task *st = task_context(t); para_fd_set(st->fd, &s->rfds, &s->max_fileno); } @@ -762,10 +762,13 @@ static void register_signal_task(struct sched *s) para_install_sighandler(SIGTERM); para_install_sighandler(SIGHUP); - st->task.pre_select = signal_pre_select; - st->task.post_select = afs_signal_post_select; - sprintf(st->task.status, "signal task"); - register_task(s, &st->task); + st->task = task_register(&(struct task_info) { + .name = "signal", + .pre_select = signal_pre_select, + .post_select = afs_signal_post_select, + .context = st, + + }, s); } static struct list_head afs_client_list; diff --git a/audiod.c b/audiod.c index 1d8cc4c1..afdb97f7 100644 --- a/audiod.c +++ b/audiod.c @@ -1006,7 +1006,7 @@ err: static void signal_pre_select(struct sched *s, struct task *t) { - struct signal_task *st = container_of(t, struct signal_task, task); + struct signal_task *st = task_context(t); para_fd_set(st->fd, &s->rfds, &s->max_fileno); } @@ -1025,13 +1025,6 @@ static int signal_post_select(struct sched *s, __a_unused struct task *t) return 0; } -static void signal_setup_default(struct signal_task *st) -{ - st->task.pre_select = signal_pre_select; - st->task.post_select = signal_post_select; - sprintf(st->task.status, "signal task"); -} - static void command_pre_select(struct sched *s, struct task *t) { struct command_task *ct = container_of(t, struct command_task, task); @@ -1422,7 +1415,6 @@ int main(int argc, char *argv[]) FOR_EACH_SLOT(i) clear_slot(i); setup_signal_handling(); - signal_setup_default(sig_task); init_status_task(stat_task); init_command_task(cmd_task); @@ -1430,7 +1422,12 @@ int main(int argc, char *argv[]) if (conf.daemon_given) daemonize(false /* parent exits immediately */); - register_task(&sched, &sig_task->task); + sig_task->task = task_register(&(struct task_info) { + .name = "signal", + .pre_select = signal_pre_select, + .post_select = signal_post_select, + .context = sig_task, + }, &sched); register_task(&sched, &cmd_task->task); register_task(&sched, &stat_task->task); sched.default_timeout.tv_sec = 2; diff --git a/server.c b/server.c index ab7c3c1b..1d67b8b8 100644 --- a/server.c +++ b/server.c @@ -237,7 +237,7 @@ out: static void signal_pre_select(struct sched *s, struct task *t) { - struct signal_task *st = container_of(t, struct signal_task, task); + struct signal_task *st = task_context(t); para_fd_set(st->fd, &s->rfds, &s->max_fileno); } @@ -312,10 +312,6 @@ static void init_signal_task(void) static struct signal_task signal_task_struct, *st = &signal_task_struct; - st->task.pre_select = signal_pre_select; - st->task.post_select = signal_post_select; - sprintf(st->task.status, "signal task"); - PARA_NOTICE_LOG("setting up signal handling\n"); st->fd = para_signal_init(); /* always successful */ para_install_sighandler(SIGINT); @@ -324,7 +320,13 @@ static void init_signal_task(void) para_install_sighandler(SIGCHLD); para_sigaction(SIGPIPE, SIG_IGN); add_close_on_fork_list(st->fd); - register_task(&sched, &st->task); + st->task = task_register(&(struct task_info) { + .name = "signal", + .pre_select = signal_pre_select, + .post_select = signal_post_select, + .context = st, + + }, &sched); } static void command_pre_select(struct sched *s, struct task *t) diff --git a/signal.h b/signal.h index 526f1502..a15349ca 100644 --- a/signal.h +++ b/signal.h @@ -13,7 +13,7 @@ struct signal_task { /** The signal pipe. */ int fd; /** The associated task structure. */ - struct task task; + struct task *task; }; int para_signal_init(void);