diff options
author | Joey Hess <joey@kitenet.net> | 2011-11-25 11:46:07 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-11-25 11:51:06 -0400 |
commit | 12243d2279cae65ed163bdec1edb268817514265 (patch) | |
tree | 9e8dfecb67c8e070a2e9d929d4ee9bf142bbc369 /debian | |
parent | 566a5f4881ef036d748ebc55140358087aaae63c (diff) |
Flush json output, avoiding a buffering problem that could result in doubled output.
The bug was that with --json, output lines were sometimes doubled. For
example, git annex init --json would output two lines, despite only running
one thing. Adding to the weirdness, this only occurred when the output
was redirected to a pipe or a file.
Strace showed two processes outputting the same buffered output.
The second process was this writer process (only needed to work around
bug #624389):
_ <- forkProcess $ do
hPutStr toh $ unlines paths
hClose toh
exitSuccess
The doubled output occurs when this process exits, and ghc flushes the
inherited stdout buffer. Why only when piping? I don't know, but ghc may
be behaving differently when stdout is not a terminal.
While this is quite possibly a ghc bug, there is a nice fix in git-annex.
Explicitly flushing after each chunk of json is output works around the
problem, and as a side effect, json is streamed rather than being output
all at the end when performing an expensive operaition.
However, note that this means all uses of putStr in git-annex must be
explicitly flushed. The others were, already.
Diffstat (limited to 'debian')
-rw-r--r-- | debian/changelog | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog index e043f6c9f..cbf69b741 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,8 @@ git-annex (3.20111123) UNRELEASED; urgency=low * Put a workaround in the directory special remote for strange behavior with VFAT filesystems on Linux (mounted with shortname=mixed) + * Flush json output, avoiding a buffering problem that could result in + doubled output. -- Joey Hess <joeyh@debian.org> Tue, 22 Nov 2011 17:53:42 -0400 |