]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - afs.c
Fix a bug in the mood line parser.
[paraslash.git] / afs.c
diff --git a/afs.c b/afs.c
index 9d235b35bc9cd68d4c5d7b85ce24aa702cb2cd1b..c2ac0e4110e15ceac8f677947894e2a1afd057b4 100644 (file)
--- a/afs.c
+++ b/afs.c
@@ -460,7 +460,7 @@ static int pass_afd(int fd, char *buf, size_t size)
 
        /* Sum of the length of all control messages in the buffer */
        msg.msg_controllen = cmsg->cmsg_len;
-       PARA_NOTICE_LOG("passing %zu bytes and fd %d\n", size, fd);
+       PARA_DEBUG_LOG("passing %zu bytes and fd %d\n", size, fd);
        ret = sendmsg(server_socket, &msg, 0);
        if (ret < 0) {
                ret = -ERRNO_TO_PARA_ERROR(errno);
@@ -487,7 +487,7 @@ int open_next_audio_file(void)
        int ret, shmid;
        char buf[8];
 
-       PARA_NOTICE_LOG("getting next af\n");
+       PARA_NOTICE_LOG("getting next audio file\n");
        ret = score_get_best(&aft_row, &afd.score);
        if (ret < 0)
                return ret;
@@ -495,7 +495,6 @@ int open_next_audio_file(void)
        if (ret < 0)
                return ret;
        shmid = ret;
-       PARA_NOTICE_LOG("shmid: %u\n", shmid);
        if (!write_ok(server_socket)) {
                PARA_EMERG_LOG("afs_socket not writable\n");
                goto destroy;
@@ -603,16 +602,10 @@ int com_select(int fd, int argc, char * const * const argv)
        return ret;
 }
 
-static void init_admissible_files(void)
+static void init_admissible_files(char *arg)
 {
-       int ret = 0;
-       char *arg = conf.afs_initial_mode_arg;
-       ret = activate_mood_or_playlist(arg, NULL);
-       if (ret >= 0)
-               return;
-       PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
-       PARA_NOTICE_LOG("defaulting to dummy mood\n");
-       activate_mood_or_playlist(NULL, NULL); /* always successful */
+       if (activate_mood_or_playlist(arg, NULL) < 0)
+               activate_mood_or_playlist(NULL, NULL); /* always successful */
 }
 
 static int setup_command_socket_or_die(void)
@@ -678,6 +671,8 @@ static int open_afs_tables(void)
        int i, ret;
 
        get_database_dir();
+       PARA_NOTICE_LOG("opening %u osl tables in %s\n", NUM_AFS_TABLES,
+               database_dir);
        for (i = 0; i < NUM_AFS_TABLES; i++) {
                ret = afs_tables[i].open(database_dir);
                if (ret >= 0)
@@ -722,9 +717,9 @@ static void signal_post_select(struct sched *s, struct task *t)
        if (st->signum == SIGHUP) {
                close_afs_tables();
                t->ret = open_afs_tables();
-               /* FIXME: Restore current mood or playlist */
                if (t->ret < 0)
                        goto err;
+               init_admissible_files(current_mop);
                return;
        }
        t->ret = -E_AFS_SIGNAL;
@@ -836,10 +831,11 @@ static void execute_server_command(void)
                return;
        }
        buf[ret] = '\0';
-       PARA_NOTICE_LOG("received: %s\n", buf);
+       PARA_DEBUG_LOG("received: %s\n", buf);
        if (!strcmp(buf, "new")) {
                ret = open_next_audio_file();
-               PARA_NOTICE_LOG("ret: %d\n", ret);
+               if (ret < 0)
+                       PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
                return;
        }
        PARA_ERROR_LOG("unknown command\n");
@@ -966,7 +962,7 @@ __noreturn void afs_init(uint32_t cookie, int socket_fd)
                exit(EXIT_FAILURE);
        PARA_INFO_LOG("server_socket: %d, afs_socket_cookie: %u\n",
                server_socket, (unsigned) cookie);
-       init_admissible_files();
+       init_admissible_files(conf.afs_initial_mode_arg);
        register_tasks(cookie);
        s.default_timeout.tv_sec = 0;
        s.default_timeout.tv_usec = 999 * 1000;