Commit 819a23d8 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Don't need a sync.WaitGroup here

parent 59c95c75
...@@ -6,7 +6,6 @@ import ( ...@@ -6,7 +6,6 @@ import (
"io" "io"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"sync"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/api" "gitlab.com/gitlab-org/gitlab-workhorse/internal/api"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper" "gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
...@@ -51,23 +50,19 @@ func handleUploadPack(action string, w *GitHttpResponseWriter, r *http.Request, ...@@ -51,23 +50,19 @@ func handleUploadPack(action string, w *GitHttpResponseWriter, r *http.Request,
defer helper.CleanUpProcessGroup(cmd) // Ensure brute force subprocess clean-up defer helper.CleanUpProcessGroup(cmd) // Ensure brute force subprocess clean-up
stdoutError := make(chan error, 1) stdoutError := make(chan error, 1)
var wg sync.WaitGroup
wg.Add(1)
// Start writing the response // Start writing the response
writePostRPCHeader(w, action) writePostRPCHeader(w, action)
go func() { go func() {
defer wg.Done() _, err := io.Copy(w, stdout)
if err != nil {
if _, err := io.Copy(w, stdout); err != nil {
helper.LogError( helper.LogError(
r, r,
&copyError{fmt.Errorf("handleUploadPack: copy output of %v: %v", cmd.Args, err)}, &copyError{fmt.Errorf("handleUploadPack: copy output of %v: %v", cmd.Args, err)},
) )
stdoutError <- err
return
} }
stdoutError <- err
}() }()
// Write the client request body to Git's standard input // Write the client request body to Git's standard input
...@@ -78,10 +73,9 @@ func handleUploadPack(action string, w *GitHttpResponseWriter, r *http.Request, ...@@ -78,10 +73,9 @@ func handleUploadPack(action string, w *GitHttpResponseWriter, r *http.Request,
// Signal to the Git subprocess that no more data is coming // Signal to the Git subprocess that no more data is coming
stdin.Close() stdin.Close()
wg.Wait()
if len(stdoutError) > 0 { if err := <-stdoutError; err != nil {
return return writtenIn, err
} }
err = cmd.Wait() err = cmd.Wait()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment