summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4d69065)
raw | patch | inline | side by side (parent: 4d69065)
author | Franck Bui-Huu <vagabon.xyz@gmail.com> | |
Sun, 17 Sep 2006 14:09:18 +0000 (16:09 +0200) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sun, 17 Sep 2006 21:47:18 +0000 (14:47 -0700) |
The current code works like this: if others flags than POLLIN is
raised we assume that (a) something bad happened and the child died or
(b) the child has closed the pipe because it had no more data to send.
For the latter case, we assume wrongly that one call to
process_input() will empty the pipe. Indeed it reads only 16Ko of data
by call and the the pipe capacity can be larger than that (on current
Linux kernel, it is 65536 bytes). Therefore the child can write 32ko
of data, for example, and close the pipe. After that poll will return
POLLIN _and_ POLLHUP and the parent will read only 16ko of data.
This patch forces the parent to empty the pipe as soon as POLLIN is
raised and even if POLLHUP or something else is raised too.
Moreover, some implementations of poll might return POLLRDNORM flag
even if it is non standard.
Signed-off-by: Franck Bui-Huu <vagabon.xyz@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
raised we assume that (a) something bad happened and the child died or
(b) the child has closed the pipe because it had no more data to send.
For the latter case, we assume wrongly that one call to
process_input() will empty the pipe. Indeed it reads only 16Ko of data
by call and the the pipe capacity can be larger than that (on current
Linux kernel, it is 65536 bytes). Therefore the child can write 32ko
of data, for example, and close the pipe. After that poll will return
POLLIN _and_ POLLHUP and the parent will read only 16ko of data.
This patch forces the parent to empty the pipe as soon as POLLIN is
raised and even if POLLHUP or something else is raised too.
Moreover, some implementations of poll might return POLLRDNORM flag
even if it is non standard.
Signed-off-by: Franck Bui-Huu <vagabon.xyz@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
builtin-upload-archive.c | patch | blob | history |
index 115a12dc13a09e9bfd4c965ca632709e0f1cd89b..0596865679d79e1f02877ea47fb910a7c771f38f 100644 (file)
--- a/builtin-upload-archive.c
+++ b/builtin-upload-archive.c
if (pfd[1].revents & POLLIN)
/* Status stream ready */
process_input(pfd[1].fd, 2);
- if ((pfd[0].revents | pfd[1].revents) == POLLIN)
+ /* Always finish to read data when available */
+ if ((pfd[0].revents | pfd[1].revents) & POLLIN)
continue;
if (waitpid(writer, &status, 0) < 0)