sched: Allow more than one running scheduler instance.
[paraslash.git] / afs.c
diff --git a/afs.c b/afs.c
index 3f37805..b4c85dc 100644 (file)
--- a/afs.c
+++ b/afs.c
@@ -727,11 +727,11 @@ static void afs_signal_post_select(struct sched *s, struct task *t)
        }
        PARA_EMERG_LOG("terminating on signal %d\n", signum);
 shutdown:
-       sched_shutdown();
+       sched_shutdown(s);
        t->error = -E_AFS_SIGNAL;
 }
 
-static void register_signal_task(void)
+static void register_signal_task(struct sched *s)
 {
        struct signal_task *st = &signal_task_struct;
 
@@ -745,7 +745,7 @@ static void register_signal_task(void)
        st->task.pre_select = signal_pre_select;
        st->task.post_select = afs_signal_post_select;
        sprintf(st->task.status, "signal task");
-       register_task(&st->task);
+       register_task(s, &st->task);
 }
 
 static struct list_head afs_client_list;
@@ -906,7 +906,7 @@ static void command_post_select(struct sched *s, struct task *t)
        ret = execute_server_command(&s->rfds);
        if (ret < 0) {
                PARA_EMERG_LOG("%s\n", para_strerror(-ret));
-               sched_shutdown();
+               sched_shutdown(s);
                return;
        }
        /* Check the list of connected clients. */
@@ -941,7 +941,7 @@ static void command_post_select(struct sched *s, struct task *t)
        para_list_add(&client->node, &afs_client_list);
 }
 
-static void register_command_task(uint32_t cookie)
+static void register_command_task(uint32_t cookie, struct sched *s)
 {
        struct command_task *ct = &command_task_struct;
        ct->fd = setup_command_socket_or_die();
@@ -950,7 +950,7 @@ static void register_command_task(uint32_t cookie)
        ct->task.pre_select = command_pre_select;
        ct->task.post_select = command_post_select;
        sprintf(ct->task.status, "afs command task");
-       register_task(&ct->task);
+       register_task(s, &ct->task);
 }
 
 /**
@@ -964,7 +964,7 @@ __noreturn void afs_init(uint32_t cookie, int socket_fd)
        static struct sched s;
        int i, ret;
 
-       register_signal_task();
+       register_signal_task(&s);
        INIT_LIST_HEAD(&afs_client_list);
        for (i = 0; i < NUM_AFS_TABLES; i++)
                afs_tables[i].init(&afs_tables[i]);
@@ -978,7 +978,7 @@ __noreturn void afs_init(uint32_t cookie, int socket_fd)
        PARA_INFO_LOG("server_socket: %d, afs_socket_cookie: %u\n",
                server_socket, (unsigned) cookie);
        init_admissible_files(conf.afs_initial_mode_arg);
-       register_command_task(cookie);
+       register_command_task(cookie, &s);
        s.default_timeout.tv_sec = 0;
        s.default_timeout.tv_usec = 999 * 1000;
        ret = schedule(&s);