]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - afs.c
afs.c: Remove outdated comment.
[paraslash.git] / afs.c
diff --git a/afs.c b/afs.c
index e73c668fb6d93b3a200eb841e4d4c34ce4b48e59..53fa5379dc906ccb173535ab06bbe9c770f4b25a 100644 (file)
--- a/afs.c
+++ b/afs.c
@@ -365,8 +365,11 @@ static int action_if_pattern_matches(struct osl_row *row, void *data)
        name = (char *)name_obj.data;
        if ((!name || !*name) && (pmd->pm_flags & PM_SKIP_EMPTY_NAME))
                return 1;
-       if (!pmd->patterns.size && (pmd->pm_flags & PM_NO_PATTERN_MATCHES_EVERYTHING))
+       if (pmd->patterns.size == 0 &&
+                       (pmd->pm_flags & PM_NO_PATTERN_MATCHES_EVERYTHING)) {
+               pmd->num_matches++;
                return pmd->action(pmd->table, row, name, pmd->data);
+       }
        for (p = pattern_txt; p < pattern_txt + pmd->patterns.size;
                        p += strlen(p) + 1) {
                ret = fnmatch(p, name, pmd->fnmatch_flags);
@@ -455,7 +458,7 @@ static int pass_afd(int fd, char *buf, size_t size)
 }
 
 /**
- * Open the audio file with highest score.
+ * Pass the fd of the next audio file to the server process.
  *
  * This stores all information for streaming the "best" audio file in a shared
  * memory area. The id of that area and an open file descriptor for the next
@@ -467,27 +470,15 @@ static int pass_afd(int fd, char *buf, size_t size)
  */
 static int open_next_audio_file(void)
 {
-       struct osl_row *aft_row;
        struct audio_file_data afd;
        int ret, shmid;
        char buf[8];
-       long score;
-again:
-       PARA_NOTICE_LOG("getting next audio file\n");
-       ret = score_get_best(&aft_row, &score);
+
+       ret = open_and_update_audio_file(&afd);
        if (ret < 0) {
                PARA_ERROR_LOG("%s\n", para_strerror(-ret));
                goto no_admissible_files;
        }
-       ret = open_and_update_audio_file(aft_row, score, &afd);
-       if (ret < 0) {
-               ret = score_delete(aft_row);
-               if (ret < 0) {
-                       PARA_ERROR_LOG("%s\n", para_strerror(-ret));
-                       goto no_admissible_files;
-               }
-               goto again;
-       }
        shmid = ret;
        if (!write_ok(server_socket)) {
                ret = -E_AFS_SOCKET;
@@ -829,11 +820,6 @@ err:
        return ret;
 }
 
-/*
- * On errors, negative value is written to fd.
- * On success: If query produced a result, the result_shmid is written to fd.
- * Otherwise, zero is written.
- */
 static int call_callback(int fd, int query_shmid)
 {
        void *query_shm;
@@ -1011,7 +997,13 @@ static void create_tables_callback(int fd, const struct osl_object *query)
 {
        uint32_t table_mask = *(uint32_t *)query->data;
        int i, ret;
-       struct para_buffer pb = {.buf = NULL};
+       struct para_buffer pb = {
+               .max_size = shm_get_shmmax(),
+               .private_data = &(struct afs_max_size_handler_data) {
+                       .fd = fd,
+                       .band = SBD_OUTPUT
+               }
+       };
 
        close_afs_tables();
        for (i = 0; i < NUM_AFS_TABLES; i++) {
@@ -1060,9 +1052,8 @@ int com_init(struct command_context *cc)
                                return -E_BAD_TABLE_NAME;
                }
        }
-       ret = send_callback_request(create_tables_callback, &query,
+       return send_callback_request(create_tables_callback, &query,
                afs_cb_result_handler, cc);
-       return ret;
 }
 
 /**