aboutsummaryrefslogtreecommitdiff
path: root/builtin-upload-archive.c
diff options
context:
space:
mode:
authorFranck Bui-Huu <vagabon.xyz@gmail.com>2006-09-17 16:09:18 +0200
committerJunio C Hamano <junkio@cox.net>2006-09-17 14:47:18 -0700
commit9c95fbf94f9a801d04dbe38898909def7a99793f (patch)
tree384ee6e9e302e6cb73085c73a2fc623da56d9dee /builtin-upload-archive.c
parent4d69065d3adad480b79831ca9f08536aaf563dba (diff)
downloadgit-9c95fbf94f9a801d04dbe38898909def7a99793f.tar.gz
git-9c95fbf94f9a801d04dbe38898909def7a99793f.tar.xz
upload-archive: monitor child communication even more carefully.
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>
Diffstat (limited to 'builtin-upload-archive.c')
-rw-r--r--builtin-upload-archive.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/builtin-upload-archive.c b/builtin-upload-archive.c
index 115a12dc1..059686567 100644
--- a/builtin-upload-archive.c
+++ b/builtin-upload-archive.c
@@ -160,7 +160,8 @@ int cmd_upload_archive(int argc, const char **argv, const char *prefix)
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)