Commit 1fd0e32
committed
upload-pack: fix race condition in error messages
Test t5516-fetch-push.sh has a test 'deny fetch unreachable SHA1,
allowtipsha1inwant=true' that checks stderr for a specific error
string from the remote. In some build environments the error sent
over the remote connection gets mingled with the error from the
die() statement. Since both signals are being output to the same
file descriptor (but from parent and child processes), the output
we are matching with grep gets split.
To remove this failure, follow this process instead:
1. Write an error message to stderr.
2. Write an error message across the connection.
3. Flush the connection.
4. exit(1).
This reorders the events so the error is written entirely before
the client receives a message from the remote, removing the race
condition. The flush is important for avoiding a client error when
the connection is cut in the middle of a packet line.
Signed-off-by: Derrick Stolee <[email protected]>1 parent 5fa0f52 commit 1fd0e32
1 file changed
+4
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
613 | 613 | | |
614 | 614 | | |
615 | 615 | | |
| 616 | + | |
| 617 | + | |
616 | 618 | | |
617 | 619 | | |
618 | 620 | | |
619 | | - | |
620 | | - | |
| 621 | + | |
| 622 | + | |
621 | 623 | | |
622 | 624 | | |
623 | 625 | | |
| |||
0 commit comments