aboutsummaryrefslogtreecommitdiffstats
path: root/remote.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2019-03-04 10:48:28 +0100
committerGitHub <noreply@github.com>2019-03-04 10:48:28 +0100
commitaf1e3817a80cccb560b25b0fd3343894754020ba (patch)
tree451661799b2619458b36359a79c7ee58f5d8a715 /remote.go
parent0106daba16494c33d330168e38c8a610b7a9b32c (diff)
parentfae29fbd5895363ef5464cc12029db85a1a24529 (diff)
downloadgo-git-af1e3817a80cccb560b25b0fd3343894754020ba.tar.gz
Merge pull request #1080 from jfontan/fix/blocked-goroutine-remote-push
git: fix goroutine block while pushing a remote
Diffstat (limited to 'remote.go')
-rw-r--r--remote.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/remote.go b/remote.go
index de537ce..8060409 100644
--- a/remote.go
+++ b/remote.go
@@ -1020,7 +1020,12 @@ func pushHashes(
if err != nil {
return nil, err
}
- done := make(chan error)
+
+ // Set buffer size to 1 so the error message can be written when
+ // ReceivePack fails. Otherwise the goroutine will be blocked writing
+ // to the channel.
+ done := make(chan error, 1)
+
go func() {
e := packfile.NewEncoder(wr, s, useRefDeltas)
if _, err := e.Encode(hs, config.Pack.Window); err != nil {
@@ -1033,6 +1038,8 @@ func pushHashes(
rs, err := sess.ReceivePack(ctx, req)
if err != nil {
+ // close the pipe to unlock encode write
+ _ = rd.Close()
return nil, err
}