Skip to content

Commit 7c12007

Browse files
peffgitster
authored andcommitted
t1400: avoid SIGPIPE race condition on fifo
t1400.190 sometimes fails or even hangs because of the way it uses fifos. Our goal is to interactively read and write lines from update-ref, so we have two fifos, in and out. We open a descriptor connected to "in" and redirect output to that, so that update-ref does not see EOF as it would if we opened and closed it for each "echo" call. But we don't do the same for the output. This leads to a race where our "read response <out" has not yet opened the fifo, but update-ref tries to write to it and gets SIGPIPE. This can result in the test failing, or worse, hanging as we wait forever for somebody to write to the pipe. This is the same proble we fixed in 4783e7e (t0008: avoid SIGPIPE race condition on fifo, 2013-07-12), and we can fix it the same way, by opening a second long-running descriptor. Before this patch, running: ./t1400-update-ref.sh --run=1,190 --stress failed or hung within a few dozen iterations. After it, I ran it for several hundred without problems. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent efa3d64 commit 7c12007

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

t/t1400-update-ref.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,19 +1603,21 @@ test_expect_success PIPE 'transaction flushes status updates' '
16031603
(git update-ref --stdin <in >out &) &&
16041604
16051605
exec 9>in &&
1606+
exec 8<out &&
16061607
test_when_finished "exec 9>&-" &&
1608+
test_when_finished "exec 8<&-" &&
16071609
16081610
echo "start" >&9 &&
16091611
echo "start: ok" >expected &&
1610-
read line <out &&
1612+
read line <&8 &&
16111613
echo "$line" >actual &&
16121614
test_cmp expected actual &&
16131615
16141616
echo "create refs/heads/flush $A" >&9 &&
16151617
16161618
echo prepare >&9 &&
16171619
echo "prepare: ok" >expected &&
1618-
read line <out &&
1620+
read line <&8 &&
16191621
echo "$line" >actual &&
16201622
test_cmp expected actual &&
16211623
@@ -1625,7 +1627,7 @@ test_expect_success PIPE 'transaction flushes status updates' '
16251627
16261628
echo commit >&9 &&
16271629
echo "commit: ok" >expected &&
1628-
read line <out &&
1630+
read line <&8 &&
16291631
echo "$line" >actual &&
16301632
test_cmp expected actual
16311633
'

0 commit comments

Comments
 (0)