X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=aft.c;h=097b2b59c82c12dc448df5ed81360060672f0ded;hp=c724670391bcbdde581d6cfc6c45342ef1f57650;hb=23b121a85984baa9252f4b4c0b8c4f186e394bb7;hpb=d5a9e8c8eefe170b6fb62be563c079c818bd3bf8 diff --git a/aft.c b/aft.c index c7246703..097b2b59 100644 --- a/aft.c +++ b/aft.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2012 Andre Noll + * Copyright (C) 2007-2013 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -1277,8 +1277,10 @@ static int prepare_ls_row(struct osl_row *row, void *ls_opts) ret = get_score_and_aft_row(row, &score, &aft_row); if (ret < 0) return ret; - } else + } else { aft_row = row; + score = 0; + } ret = get_audio_file_path_of_row(aft_row, &path); if (ret < 0) return ret; @@ -1356,6 +1358,7 @@ static void com_ls_callback(int fd, const struct osl_object *query) .max_size_handler = afs_max_size_handler, .private_data = &(struct afs_max_size_handler_data) { .fd = fd, + .band = SBD_OUTPUT } }; int i = 0, ret; @@ -1399,7 +1402,7 @@ static void com_ls_callback(int fd, const struct osl_object *query) } out: if (b.offset) - pass_buffer_as_shm(fd, b.buf, b.offset); + pass_buffer_as_shm(fd, SBD_OUTPUT, b.buf, b.offset); free(b.buf); free(opts->data); free(opts->data_ptr); @@ -1685,6 +1688,7 @@ static void com_add_callback(int fd, const struct osl_object *query) .max_size_handler = afs_max_size_handler, .private_data = &(struct afs_max_size_handler_data) { .fd = fd, + .band = SBD_OUTPUT } }; uint16_t afhi_offset, chunks_offset; @@ -1807,7 +1811,7 @@ out: if (ret < 0) para_printf(&msg, "%s\n", para_strerror(-ret)); if (msg.offset) - pass_buffer_as_shm(fd, msg.buf, msg.offset); + pass_buffer_as_shm(fd, SBD_OUTPUT, msg.buf, msg.offset); free(msg.buf); } @@ -1826,7 +1830,8 @@ static void path_brother_callback(int fd, const struct osl_object *query) int ret = aft_get_row_of_path(path, &path_brother); if (ret < 0) return; - pass_buffer_as_shm(fd, (char *)&path_brother, sizeof(path_brother)); + pass_buffer_as_shm(fd, SBD_OUTPUT, (char *)&path_brother, + sizeof(path_brother)); } static void hash_sister_callback(int fd, const struct osl_object *query) @@ -1837,10 +1842,12 @@ static void hash_sister_callback(int fd, const struct osl_object *query) hash_sister = find_hash_sister(hash); if (!hash_sister) return; - pass_buffer_as_shm(fd, (char *)&hash_sister, sizeof(hash_sister)); + pass_buffer_as_shm(fd, SBD_OUTPUT, (char *)&hash_sister, + sizeof(hash_sister)); } -static int get_row_pointer_from_result(struct osl_object *result, void *private) +static int get_row_pointer_from_result(struct osl_object *result, + __a_unused uint8_t band, void *private) { struct osl_row **row = private; *row = *(struct osl_row **)(result->data); @@ -1869,8 +1876,12 @@ static int add_one_audio_file(const char *path, void *private_data) ret = 1; if (pb && (pad->flags & ADD_FLAG_LAZY)) { /* lazy is really cheap */ if (pad->flags & ADD_FLAG_VERBOSE) - send_ret = sc_send_va_buffer(&pad->cc->scc, - "lazy-ignore: %s\n", path); + send_ret = pad->cc->use_sideband? + send_sb_va(&pad->cc->scc, SBD_OUTPUT, + "lazy-ignore: %s\n", path) + : + sc_send_va_buffer(&pad->cc->scc, + "lazy-ignore: %s\n", path); goto out_free; } /* We still want to add this file. Compute its hash. */ @@ -1890,8 +1901,12 @@ static int add_one_audio_file(const char *path, void *private_data) ret = 1; if (pb && hs && hs == pb && !(pad->flags & ADD_FLAG_FORCE)) { if (pad->flags & ADD_FLAG_VERBOSE) - send_ret = sc_send_va_buffer(&pad->cc->scc, - "%s exists, not forcing update\n", path); + send_ret = pad->cc->use_sideband? + send_sb_va(&pad->cc->scc, SBD_OUTPUT, + "%s exists, not forcing update\n", path) + : + sc_send_va_buffer(&pad->cc->scc, + "%s exists, not forcing update\n", path); goto out_unmap; } /* @@ -1908,7 +1923,12 @@ static int add_one_audio_file(const char *path, void *private_data) munmap(map.data, map.size); close(fd); if (pad->flags & ADD_FLAG_VERBOSE) { - send_ret = sc_send_va_buffer(&pad->cc->scc, "adding %s\n", path); + send_ret = pad->cc->use_sideband? + send_sb_va(&pad->cc->scc, SBD_OUTPUT, + "adding %s\n", path) + : + sc_send_va_buffer(&pad->cc->scc, + "adding %s\n", path); if (send_ret < 0) goto out_free; } @@ -1923,8 +1943,14 @@ out_unmap: munmap(map.data, map.size); out_free: if (ret < 0 && send_ret >= 0) - send_ret = sc_send_va_buffer(&pad->cc->scc, - "failed to add %s (%s)\n", path, para_strerror(-ret)); + send_ret = pad->cc->use_sideband? + send_sb_va(&pad->cc->scc, SBD_ERROR_LOG, + "failed to add %s (%s)\n", path, + para_strerror(-ret)) + : + sc_send_va_buffer(&pad->cc->scc, + "failed to add %s (%s)\n", path, + para_strerror(-ret)); free(obj.data); clear_afhi(afhi_ptr); /* Stop adding files only on send errors. */ @@ -1968,7 +1994,11 @@ int com_add(struct command_context *cc) char *path; ret = verify_path(cc->argv[i], &path); if (ret < 0) { - ret = sc_send_va_buffer(&cc->scc, "%s: %s\n", + ret = cc->use_sideband? + send_sb_va(&cc->scc, SBD_ERROR_LOG, "%s: %s\n", + cc->argv[i], para_strerror(-ret)) + : + sc_send_va_buffer(&cc->scc, "%s: %s\n", cc->argv[i], para_strerror(-ret)); if (ret < 0) return ret; @@ -1976,9 +2006,14 @@ int com_add(struct command_context *cc) } ret = stat(path, &statbuf); if (ret < 0) { - ret = sc_send_va_buffer(&cc->scc, - "failed to stat %s (%s)\n", path, - strerror(errno)); + ret = cc->use_sideband? + send_sb_va(&cc->scc, SBD_ERROR_LOG, + "failed to stat %s (%s)\n", path, + strerror(errno)) + : + sc_send_va_buffer(&cc->scc, + "failed to stat %s (%s)\n", path, + strerror(errno)); free(path); if (ret < 0) return ret; @@ -1990,8 +2025,12 @@ int com_add(struct command_context *cc) else ret = add_one_audio_file(path, &pad); if (ret < 0) { - sc_send_va_buffer(&cc->scc, "%s: %s\n", path, - para_strerror(-ret)); + if (cc->use_sideband) + send_sb_va(&cc->scc, SBD_OUTPUT, "%s: %s\n", path, + para_strerror(-ret)); + else + sc_send_va_buffer(&cc->scc, "%s: %s\n", path, + para_strerror(-ret)); free(path); return ret; } @@ -2115,7 +2154,7 @@ static void com_touch_callback(int fd, const struct osl_object *query) else if (pmd.num_matches == 0) ret2 = para_printf(&tad.pb, "no matches\n"); if (ret2 >= 0 && tad.pb.offset) - pass_buffer_as_shm(fd, tad.pb.buf, tad.pb.offset); + pass_buffer_as_shm(fd, SBD_OUTPUT, tad.pb.buf, tad.pb.offset); free(tad.pb.buf); } @@ -2189,7 +2228,7 @@ int com_touch(struct command_context *cc) ret = send_option_arg_callback_request(&query, cc->argc - i, cc->argv + i, com_touch_callback, afs_cb_result_handler, cc); if (ret < 0) - sc_send_va_buffer(&cc->scc, "%s\n", para_strerror(-ret)); + send_strerror(cc, -ret); return ret; } @@ -2262,7 +2301,7 @@ static void com_rm_callback(int fd, const struct osl_object *query) pmd.num_matches); } if (ret >= 0 && crd.pb.offset) - pass_buffer_as_shm(fd, crd.pb.buf, crd.pb.offset); + pass_buffer_as_shm(fd, SBD_OUTPUT, crd.pb.buf, crd.pb.offset); free(crd.pb.buf); } @@ -2300,7 +2339,7 @@ int com_rm(struct command_context *cc) ret = send_option_arg_callback_request(&query, cc->argc - i, cc->argv + i, com_rm_callback, afs_cb_result_handler, cc); if (ret < 0) - sc_send_va_buffer(&cc->scc, "%s\n", para_strerror(-ret)); + send_strerror(cc, -ret); return ret; } @@ -2408,7 +2447,7 @@ out: para_printf(&cad.pb, "nothing copied\n"); } if (cad.pb.offset) - pass_buffer_as_shm(fd, cad.pb.buf, cad.pb.offset); + pass_buffer_as_shm(fd, SBD_OUTPUT, cad.pb.buf, cad.pb.offset); free(cad.pb.buf); } @@ -2459,7 +2498,7 @@ int com_cpsi(struct command_context *cc) ret = send_option_arg_callback_request(&options, cc->argc - i, cc->argv + i, com_cpsi_callback, afs_cb_result_handler, cc); if (ret < 0) - sc_send_va_buffer(&cc->scc, "%s\n", para_strerror(-ret)); + send_strerror(cc, -ret); return ret; } @@ -2471,7 +2510,7 @@ static void afs_stat_callback(int fd, const struct osl_object *query) if (!buf) return; - pass_buffer_as_shm(fd, buf, strlen(buf)); + pass_buffer_as_shm(fd, SBD_OUTPUT, buf, strlen(buf)); } /** @@ -2553,6 +2592,7 @@ void aft_check_callback(int fd, __a_unused const struct osl_object *query) .max_size = shm_get_shmmax(), .private_data = &(struct afs_max_size_handler_data) { .fd = fd, + .band = SBD_OUTPUT }, .max_size_handler = afs_max_size_handler }; @@ -2562,7 +2602,7 @@ void aft_check_callback(int fd, __a_unused const struct osl_object *query) return; audio_file_loop(&pb, check_audio_file); if (pb.offset) - pass_buffer_as_shm(fd, pb.buf, pb.offset); + pass_buffer_as_shm(fd, SBD_OUTPUT, pb.buf, pb.offset); free(pb.buf); }