aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2016-10-18 09:37:54 -0400
committerRuss Cox <rsc@golang.org>2016-10-19 02:26:39 +0000
commite6a901ea3ac4b37be94aaf7b0285ba1840354c4e (patch)
tree5360f1b2189e69fb10f12d66276db3a4d628dce8 /src
parente05d0140483e78c36cd03b3f6173e9f23e975645 (diff)
downloadgo-e6a901ea3ac4b37be94aaf7b0285ba1840354c4e.tar.xz
cmd/go: disable SSH connection pooling to avoid git hang
Fixes #13453. Fixes #16104. Change-Id: I4e94f606df786af8143f8649c9afde570f346301 Reviewed-on: https://go-review.googlesource.com/31353 Reviewed-by: Quentin Smith <quentin@golang.org>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/go/get.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/cmd/go/get.go b/src/cmd/go/get.go
index 01b4e015d2..4f7562b43d 100644
--- a/src/cmd/go/get.go
+++ b/src/cmd/go/get.go
@@ -98,6 +98,23 @@ func runGet(cmd *Command, args []string) {
os.Setenv("GIT_TERMINAL_PROMPT", "0")
}
+ // Disable any ssh connection pooling by Git.
+ // If a Git subprocess forks a child into the background to cache a new connection,
+ // that child keeps stdout/stderr open. After the Git subprocess exits,
+ // os /exec expects to be able to read from the stdout/stderr pipe
+ // until EOF to get all the data that the Git subprocess wrote before exiting.
+ // The EOF doesn't come until the child exits too, because the child
+ // is holding the write end of the pipe.
+ // This is unfortunate, but it has come up at least twice
+ // (see golang.org/issue/13453 and golang.org/issue/16104)
+ // and confuses users when it does.
+ // If the user has explicitly set GIT_SSH or GIT_SSH_COMMAND,
+ // assume they know what they are doing and don't step on it.
+ // But default to turning off ControlMaster.
+ if os.Getenv("GIT_SSH") == "" && os.Getenv("GIT_SSH_COMMAND") == "" {
+ os.Setenv("GIT_SSH_COMMAND", "ssh -o ControlMaster=no")
+ }
+
// Phase 1. Download/update.
var stk importStack
mode := 0