gui: Check return value of para_exec_cmdline_pid().
[paraslash.git] / server.c
index 4650f9947f01ed7fd6f1323610090ae16ef22ac4..d3a9a5ae63eecdc202a9261568b6ccc21785377e 100644 (file)
--- a/server.c
+++ b/server.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1997-2011 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 1997-2012 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
@@ -67,7 +67,6 @@
 #include <sys/time.h>
 #include <regex.h>
 #include <osl.h>
-#include <stdbool.h>
 
 #include "para.h"
 #include "error.h"
@@ -79,6 +78,7 @@
 #include "server.h"
 #include "list.h"
 #include "send.h"
+#include "sched.h"
 #include "vss.h"
 #include "config.h"
 #include "close_on_fork.h"
@@ -86,7 +86,6 @@
 #include "daemon.h"
 #include "ipc.h"
 #include "fd.h"
-#include "sched.h"
 #include "signal.h"
 #include "user_list.h"
 #include "color.h"
@@ -123,6 +122,7 @@ int mmd_mutex;
 /** The file containing user information (public key, permissions). */
 static char *user_list_file = NULL;
 
+static struct sched sched;
 
 /** The task responsible for server command handling. */
 struct server_command_task {
@@ -346,7 +346,7 @@ static void init_signal_task(void)
        para_install_sighandler(SIGCHLD);
        para_sigaction(SIGPIPE, SIG_IGN);
        add_close_on_fork_list(st->fd);
-       register_task(&st->task);
+       register_task(&sched, &st->task);
 }
 
 static void command_pre_select(struct sched *s, struct task *t)
@@ -429,7 +429,7 @@ static void init_server_command_task(int argc, char **argv)
                goto err;
        add_close_on_fork_list(sct->listen_fd); /* child doesn't need the listener */
        sprintf(sct->task.status, "server command task");
-       register_task(&sct->task);
+       register_task(&sched, &sct->task);
        return;
 err:
        PARA_EMERG_LOG("%s\n", para_strerror(-ret));
@@ -519,7 +519,7 @@ static void server_init(int argc, char **argv)
        init_signal_task();
        para_unblock_signal(SIGCHLD);
        PARA_NOTICE_LOG("initializing virtual streaming system\n");
-       init_vss_task(afs_socket);
+       init_vss_task(afs_socket, &sched);
        init_server_command_task(argc, argv);
        if (conf.daemon_given)
                kill(getppid(), SIGTERM);
@@ -571,16 +571,13 @@ static int server_select(int max_fileno, fd_set *readfds, fd_set *writefds,
 int main(int argc, char *argv[])
 {
        int ret;
-       static struct sched s = {
-               .default_timeout = {
-                       .tv_sec = 1,
-                       .tv_usec = 0
-               },
-               .select_function = server_select
-       };
+
+       sched.default_timeout.tv_sec = 1;
+       sched.select_function = server_select;
+
        server_init(argc, argv);
        mutex_lock(mmd_mutex);
-       ret = schedule(&s);
+       ret = schedule(&sched);
        if (ret < 0) {
                PARA_EMERG_LOG("%s\n", para_strerror(-ret));
                exit(EXIT_FAILURE);