{"thread":{"id":"5591","subject":"[PATCH] upload-archive: monitor child communication even more carefully.","startedAt":"2006-09-17T14:09:18Z","lastAt":"2006-09-17T14:09:18Z","messageCount":1,"participants":["Franck Bui-Huu"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"27077","messageId":"cda58cb80609170709l1f2732d4s2c606aeafd6b9257@mail.gmail.com","threadId":"5591","inReplyTo":null,"subject":"[PATCH] upload-archive: monitor child communication even more carefully.","fromName":"Franck Bui-Huu","fromEmail":"vagabon.xyz@gmail.com","sentAt":"2006-09-17T14:09:18Z","receivedAt":"2006-09-17T14:09:18Z","isPatch":true,"sender":{"key":"vagabon.xyz@gmail.com","avatar":null},"body":"The current code works like this: if others flags than POLLIN is\nraised we assume that (a) something bad happened and the child died or\n(b) the child has closed the pipe because it had no more data to send.\n\nFor the latter case, we assume wrongly that one call to\nprocess_input() will empty the pipe. Indeed it reads only 16Ko of data\nby call and the the pipe capacity can be larger than that (on current\nLinux kernel, it is 65536 bytes). Therefore the child can write 32ko\nof data, for example, and close the pipe. After that poll will return\nPOLLIN _and_ POLLHUP and the parent will read only 16ko of data.\n\nThis patch forces the parent to empty the pipe as soon as POLLIN is\nraised and even if POLLHUP or something else is raised too.\n\nMoreover, some implementations of poll might return POLLRDNORM flag\neven if it is non standard.\n\nSigned-off-by: Franck Bui-Huu <vagabon.xyz@gmail.com>\n---\n\n My own fault.\n\n builtin-upload-archive.c |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-upload-archive.c b/builtin-upload-archive.c\nindex 115a12d..0596865 100644\n--- a/builtin-upload-archive.c\n+++ b/builtin-upload-archive.c\n@@ -160,7 +160,8 @@ int cmd_upload_archive(int argc, const c\n \t\tif (pfd[1].revents & POLLIN)\n \t\t\t/* Status stream ready */\n \t\t\tprocess_input(pfd[1].fd, 2);\n-\t\tif ((pfd[0].revents | pfd[1].revents) == POLLIN)\n+\t\t/* Always finish to read data when available */\n+\t\tif ((pfd[0].revents | pfd[1].revents) & POLLIN)\n \t\t\tcontinue;\n\n \t\tif (waitpid(writer, &status, 0) < 0)\n-- \n1.4.2.1.gcd6f1-dirty\n"}]}