git-annex/debian
Joey Hess 12243d2279 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.
2011-11-25 11:51:06 -04:00
..
changelog Flush json output, avoiding a buffering problem that could result in doubled output. 2011-11-25 11:51:06 -04:00
compat debianization 2010-10-16 16:41:24 -04:00
control prep release 2011-10-11 23:03:19 -04:00
copyright file moved 2011-08-21 13:19:33 -04:00
doc-base Add doc-base file. Closes: #621408 2011-04-06 21:57:22 -04:00
manpages update 2010-10-19 16:17:29 -04:00
NEWS typo 2011-10-12 00:29:49 -04:00
rules update 2010-10-27 15:08:46 -04:00