From mboxrd@z Thu Jan 1 00:00:00 1970 From: john at keeping.me.uk (John Keeping) Date: Wed, 11 Jun 2014 21:55:19 +0100 Subject: [PATCH] ui-patch: Flush stdout after outputting data In-Reply-To: <5398BBEA.8090002@kernel.org> References: <5398B200.2080309@kernel.org> <5398BBEA.8090002@kernel.org> Message-ID: <20140611205519.GB28807@serenity.lan> On Wed, Jun 11, 2014 at 04:28:26PM -0400, Konstantin Ryabitsev wrote: > On 11/06/14 04:01 PM, John Keeping wrote: > > Since the "html" functions use raw write(2) to STDIO_FILENO, we don't > > notice problems with most pages, but raw patches write using printf(3). > > This is fine if we're outputting straight to stdout since the buffers > > are flushed on exit, but we close the cache output before this, so the > > cached output ends up being truncated. Actually, it's slightly more interesting than this... since we don't set GIT_FLUSH, Git decides whether or not it will flush stdout after writing each commit based on whether or not stdout points to a regular file (in maybe_flush_or_die()). Which means that when writing directly to the webserver, Git flushes stdout for us, but when we redirect stdout to the cache it points to a regular file so Git no longer flushes the output for us. The patch is still correct, but perhaps the full explanation is interesting!