task_register() conversion: signal task
authorAndre Noll <maan@systemlinux.org>
Mon, 30 Dec 2013 23:20:32 +0000 (23:20 +0000)
committerAndre Noll <maan@systemlinux.org>
Sun, 25 May 2014 13:39:00 +0000 (15:39 +0200)
afs.c
audiod.c
server.c
signal.h

diff --git a/afs.c b/afs.c
index fa4f432..a2789bd 100644 (file)
--- 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;
index 1d8cc4c..afdb97f 100644 (file)
--- 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;
index ab7c3c1..1d67b8b 100644 (file)
--- 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)
index 526f150..a15349c 100644 (file)
--- 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);