afs.c: Get rid of unregister_tasks().
authorAndre Noll <maan@systemlinux.org>
Tue, 1 Apr 2008 09:28:52 +0000 (11:28 +0200)
committerAndre Noll <maan@systemlinux.org>
Tue, 1 Apr 2008 09:28:52 +0000 (11:28 +0200)
Call shed_shutdown() instead. Also make read errors from the
afs - server pipe fatal.

afs.c

diff --git a/afs.c b/afs.c
index 0454b8e..fd43d59 100644 (file)
--- a/afs.c
+++ b/afs.c
@@ -747,12 +747,6 @@ static int open_afs_tables(void)
        return ret;
 }
 
-static void unregister_tasks(void)
-{
-       unregister_task(&command_task_struct.task);
-       unregister_task(&signal_task_struct.task);
-}
-
 static void signal_pre_select(struct sched *s, struct task *t)
 {
        struct signal_task *st = container_of(t, struct signal_task, task);
@@ -898,28 +892,24 @@ static int call_callback(int fd, int query_shmid)
        return 1;
 }
 
-static void execute_server_command(void)
+static int execute_server_command(void)
 {
        char buf[8];
        int ret = recv_bin_buffer(server_socket, buf, sizeof(buf) - 1);
 
        if (ret <= 0) {
-               if (ret < 0)
-                       PARA_ERROR_LOG("%s\n", para_strerror(-ret));
-               return;
+               if (!ret)
+                       ret = -ERRNO_TO_PARA_ERROR(ECONNRESET);
+               goto err;
        }
        buf[ret] = '\0';
        PARA_DEBUG_LOG("received: %s\n", buf);
-       if (!strcmp(buf, "new")) {
-               ret = open_next_audio_file();
-               if (ret < 0) {
-                       PARA_EMERG_LOG("%s\n", para_strerror(-ret));
-                       unregister_tasks();
-               }
-               return;
-       }
-       PARA_ERROR_LOG("unknown command\n");
-
+       ret = -E_BAD_CMD;
+       if (strcmp(buf, "new"))
+               goto err;
+       ret = open_next_audio_file();
+err:
+       return ret;
 }
 
 static void execute_afs_command(int fd, uint32_t expected_cookie)
@@ -964,8 +954,15 @@ static void command_post_select(struct sched *s, struct task *t)
        struct sockaddr_un unix_addr;
        struct afs_client *client, *tmp;
        int fd, ret;
-       if (FD_ISSET(server_socket, &s->rfds))
-               execute_server_command();
+
+       if (FD_ISSET(server_socket, &s->rfds)) {
+               ret = execute_server_command();
+               if (ret < 0) {
+                       PARA_EMERG_LOG("%s\n", para_strerror(-ret));
+                       sched_shutdown();
+                       return;
+               }
+       }
 
        /* Check the list of connected clients. */
        list_for_each_entry_safe(client, tmp, &afs_client_list, node) {