sched: Allow more than one running scheduler instance.
[paraslash.git] / client.c
index ec32cd414e31df10dd5c7dbecbdef60c5134a5a2..038fc0134e52adcc041fa52c152a321b9818b58e 100644 (file)
--- a/client.c
+++ b/client.c
@@ -7,7 +7,6 @@
 /** \file client.c the client program used to connect to para_server */
 
 #include <regex.h>
-#include <openssl/rc4.h>
 #include <stdbool.h>
 
 #include "para.h"
 
 INIT_CLIENT_ERRLISTS;
 
+static struct sched sched;
 static struct client_task *ct;
 static struct stdin_task sit;
 static struct stdout_task sot;
 
-static void supervisor_post_select(__a_unused struct sched *s, struct task *t)
+static void supervisor_post_select(struct sched *s, struct task *t)
 {
        if (ct->task.error < 0) {
                t->error = ct->task.error;
@@ -36,13 +36,13 @@ static void supervisor_post_select(__a_unused struct sched *s, struct task *t)
        }
        if (ct->status == CL_SENDING) {
                stdin_set_defaults(&sit);
-               register_task(&sit.task);
+               register_task(s, &sit.task);
                t->error = -E_TASK_STARTED;
                return;
        }
        if (ct->status == CL_RECEIVING) {
                stdout_set_defaults(&sot);
-               register_task(&sot.task);
+               register_task(s, &sot.task);
                t->error = -E_TASK_STARTED;
                return;
        }
@@ -83,6 +83,7 @@ int main(int argc, char *argv[])
        init_random_seed_or_die();
        s.default_timeout.tv_sec = 1;
        s.default_timeout.tv_usec = 0;
+
        /*
         * We add buffer tree nodes for stdin and stdout even though
         * only one of them will be needed. This simplifies the code
@@ -90,13 +91,13 @@ int main(int argc, char *argv[])
         */
        sit.btrn = btr_new_node(&(struct btr_node_description)
                EMBRACE(.name = "stdin"));
-       ret = client_open(argc, argv, &ct, &client_loglevel, sit.btrn, NULL);
+       ret = client_open(argc, argv, &ct, &client_loglevel, sit.btrn, NULL, &sched);
        if (ret < 0)
                goto out;
        sot.btrn = btr_new_node(&(struct btr_node_description)
                EMBRACE(.name = "stdout", .parent = ct->btrn));
-       register_task(&svt);
-       ret = schedule(&s);
+       register_task(&sched, &svt);
+       ret = schedule(&sched);
 out:
        client_close(ct);
        btr_free_node(sit.btrn);