blind

suckless command-line video editing utility
git clone git://git.suckless.org/blind
Log | Files | Refs | README | LICENSE

commit 8a974ac29d6ba6771d6934a9ac9d1b7e35f38e4f
parent d87e381c372c8c51472a7369e00f65ecab822c04
Author: Mattias Andrée <maandree@kth.se>
Date:   Sun, 15 Jan 2017 17:01:12 +0100

blind-config: fix -j

Signed-off-by: Mattias Andrée <maandree@kth.se>

Diffstat:
Msrc/blind-concat.c | 21+++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)

diff --git 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 <sys/epoll.h> #endif #include <sys/mman.h> @@ -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 }