task_register() conversion: afs command task
authorAndre Noll <maan@systemlinux.org>
Mon, 30 Dec 2013 23:34:08 +0000 (23:34 +0000)
committerAndre Noll <maan@systemlinux.org>
Sun, 25 May 2014 13:39:00 +0000 (15:39 +0200)
afs.c

diff --git a/afs.c b/afs.c
index a2789bd..7124d83 100644 (file)
--- a/afs.c
+++ b/afs.c
@@ -81,7 +81,7 @@ struct command_task {
         */
        uint32_t cookie;
        /** The associated task structure. */
-       struct task task;
+       struct task *task;
 };
 
 extern int mmd_mutex;
@@ -785,7 +785,7 @@ struct afs_client {
 
 static void command_pre_select(struct sched *s, struct task *t)
 {
-       struct command_task *ct = container_of(t, struct command_task, task);
+       struct command_task *ct = task_context(t);
        struct afs_client *client;
 
        para_fd_set(server_socket, &s->rfds, &s->max_fileno);
@@ -922,7 +922,7 @@ err:
 
 static int command_post_select(struct sched *s, struct task *t)
 {
-       struct command_task *ct = container_of(t, struct command_task, task);
+       struct command_task *ct = task_context(t);
        struct sockaddr_un unix_addr;
        struct afs_client *client, *tmp;
        int fd, ret;
@@ -975,10 +975,12 @@ static void register_command_task(uint32_t cookie, struct sched *s)
        ct->fd = setup_command_socket_or_die();
        ct->cookie = cookie;
 
-       ct->task.pre_select = command_pre_select;
-       ct->task.post_select = command_post_select;
-       sprintf(ct->task.status, "afs command task");
-       register_task(s, &ct->task);
+       ct->task = task_register(&(struct task_info) {
+               .name = "afs command",
+               .pre_select = command_pre_select,
+               .post_select = command_post_select,
+               .context = ct,
+       }, s);
 }
 
 /**
@@ -1010,6 +1012,7 @@ __noreturn void afs_init(uint32_t cookie, int socket_fd)
        s.default_timeout.tv_sec = 0;
        s.default_timeout.tv_usec = 999 * 1000;
        ret = schedule(&s);
+       sched_shutdown(&s);
 out_close:
        close_afs_tables();
 out: