From 8a974ac29d6ba6771d6934a9ac9d1b7e35f38e4f Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 15 Jan 2017 17:01:12 +0100 Subject: blind-config: fix -j MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/blind-concat.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/blind-concat.c b/src/blind-concat.c index 63a9b21..bea127a 100644 --- a/src/blind-concat.c +++ b/src/blind-concat.c @@ -2,7 +2,7 @@ #include "stream.h" #include "util.h" -#if defined(HAVE_SYS_EPOLL_H) +#if defined(HAVE_EPOLL) # include #endif #include @@ -98,6 +98,12 @@ concat_to_file(int argc, char *argv[], char *output_file) static void concat_to_file_parallel(int argc, char *argv[], char *output_file, size_t jobs) { +#if !defined(HAVE_EPOLL) + int fd = eopen(output_file, O_WRONLY | O_CREAT | O_TRUNC, 0666); + if (fd != STDOUT_FILENO && dup2(fd, STDOUT_FILENO) == -1) + eprintf("dup2:"); + concat_to_stdout(argc, argv, output_file); +#else struct epoll_event *events; struct stream *streams; size_t *ptrs; @@ -106,14 +112,6 @@ concat_to_file_parallel(int argc, char *argv[], char *output_file, size_t jobs) ssize_t headlen; int fd, i, n, pollfd; -#if !defined(HAVE_SYS_EPOLL_H) - fd = eopen(output_file, O_WRONLY | O_CREAT | O_TRUNC, 0666); - if (fd != STDOUT_FILENO && dup2(fd, STDOUT_FILENO) == -1) - eprintf("dup2:"); - concat_to_stdout(argc, argv, output_file); - return; -#else - if (jobs > (size_t)argc) jobs = (size_t)argc; @@ -153,7 +151,7 @@ concat_to_file_parallel(int argc, char *argv[], char *output_file, size_t jobs) if (pollfd == -1) eprintf("epoll_create1:"); - epwriteall(fd, head, (size_t)head_len, 0, output_file); + epwriteall(fd, head, (size_t)headlen, 0, output_file); for (i = 0; i < argc; i++) { epwriteall(fd, streams[i].buf, streams[i].ptr, ptrs[i], output_file); ptrs[i] += streams[i].ptr; @@ -177,7 +175,7 @@ concat_to_file_parallel(int argc, char *argv[], char *output_file, size_t jobs) eprintf("epoll_wait:"); for (i = 0; i < n; i++) { j = events[i].data.u64; - if (!eread_stream(streams + j)) { + if (!eread_stream(streams + j, SIZE_MAX)) { close(streams[j].fd); if (next < (size_t)argc) { events->events = EPOLLIN; @@ -203,7 +201,6 @@ concat_to_file_parallel(int argc, char *argv[], char *output_file, size_t jobs) free(events); free(streams); free(ptrs); - #endif } -- cgit v1.2.3-70-g09d2