mblaze

Unix utilities to deal with Maildir - my mirror
git clone https://pi.duncano.de/git/mblaze.git
Log | Files | Refs | README | COPYING

commit 6b5b42f5836388d467ab0c2adcca58bb2a6fb0f3
parent 8a9825596b0cff53d3cf1475ad540f23273442bb
Author: Leah Neukirchen <leah@vuxu.org>
Date:   Sun,  6 Aug 2017 18:53:51 +0200

filter: don't write more than PIPE_BUF at once

This could result in stalling during big writes when we can't read the
output of the child in the mean time.

Diffstat:
filter.c | 7+++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/filter.c b/filter.c @@ -1,9 +1,11 @@ +#include <sys/wait.h> + +#include <limits.h> #include <poll.h> #include <signal.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <sys/wait.h> #include <time.h> #include <unistd.h> @@ -83,7 +85,8 @@ filter(char *input, size_t inlen, char *cmd, char **outputo, size_t *outleno) } if (fds[1].revents & POLLOUT) { - ssize_t ret = write(fds[1].fd, input, inlen); + ssize_t ret = write(fds[1].fd, input, + inlen > PIPE_BUF ? PIPE_BUF : inlen); if (ret > 0) { input += ret; inlen -= ret;