From: "Franck Bui-Huu" <vagabon.xyz@gmail.com>
To: "Junio C Hamano" <junkio@cox.net>
Cc: "Rene Scharfe" <rene.scharfe@lsrfire.ath.cx>,
"Git Mailing List" <git@vger.kernel.org>
Subject: [PATCH] upload-archive: monitor child communication even more carefully.
Date: Sun, 17 Sep 2006 16:09:18 +0200 [thread overview]
Message-ID: <cda58cb80609170709l1f2732d4s2c606aeafd6b9257@mail.gmail.com> (raw)
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>
---
My own fault.
builtin-upload-archive.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/builtin-upload-archive.c b/builtin-upload-archive.c
index 115a12d..0596865 100644
--- a/builtin-upload-archive.c
+++ b/builtin-upload-archive.c
@@ -160,7 +160,8 @@ int cmd_upload_archive(int argc, const 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)
--
1.4.2.1.gcd6f1-dirty
reply other threads:[~2006-09-17 14:09 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cda58cb80609170709l1f2732d4s2c606aeafd6b9257@mail.gmail.com \
--to=vagabon.xyz@gmail.com \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
--cc=rene.scharfe@lsrfire.ath.cx \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).