From: Pete Wyckoff Date: Sun, 22 Apr 2012 20:30:58 +0000 (-0400) Subject: git-remote-testgit: fix race when spawning fast-import X-Git-Tag: v1.7.10.2~25^2 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/7fb8e163bdfdc5ffb69b98f3f05ef0dbade4e677?hp=7fb8e163bdfdc5ffb69b98f3f05ef0dbade4e677 git-remote-testgit: fix race when spawning fast-import Test "pushing to local repo" in t5800-remote-helpers can hang due to a race condition in git-remote-testgit. Fix it by setting stdin to unbuffered. On the writer side, "git push" invokes push_refs_with_export(), which sends to stdout the command "export\n" and immediately starts up "git fast-export". The latter writes its output stream to the same stdout. On the reader side, remote helper "git-remote-testgit" reads from stdin to get its next command. It uses getc() to read characters from libc up until \n. Libc has buffered a potentially much larger chunk of stdin. When it sees the "export\n" command, it forks "git fast-import" to read the stream. If fast-export finishes before git fast-import starts, the fast-export output can end up in libc's buffer in git-remote-testgit, rather than in git fast-import. The latter hangs indefinitely on a now-empty stdin. Signed-off-by: Pete Wyckoff Signed-off-by: Junio C Hamano ---