Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
vvatanabe committed Sep 12, 2018
2 parents 435d058 + 8c1746f commit 3f35dbe
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions githttpxfer/githttpxfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os"
"regexp"
"strings"
"sync"
)

var (
Expand Down Expand Up @@ -287,7 +288,9 @@ func (ghx *GitHTTPXfer) serviceRPC(ctx Context, rpc string) {
return
}

if _, err := io.Copy(stdin, body); err != nil {
bufIn := bufPool.Get().([]byte)
defer bufPool.Put(bufIn)
if _, err := io.CopyBuffer(stdin, body, bufIn); err != nil {
ghx.logger.Error("failed to write the request body to standard input. ", err.Error())
RenderInternalServerError(res.Writer)
return
Expand All @@ -299,7 +302,9 @@ func (ghx *GitHTTPXfer) serviceRPC(ctx Context, rpc string) {
res.SetContentType(fmt.Sprintf("application/x-git-%s-result", rpc))
res.WriteHeader(http.StatusOK)

if _, err := io.Copy(res.Writer, stdout); err != nil {
bufOut := bufPool.Get().([]byte)
defer bufPool.Put(bufOut)
if _, err := io.CopyBuffer(res.Writer, stdout, bufOut); err != nil {
ghx.logger.Error("failed to write the standard output to response. ", err.Error())
return
}
Expand All @@ -309,6 +314,12 @@ func (ghx *GitHTTPXfer) serviceRPC(ctx Context, rpc string) {
}
}

var bufPool = sync.Pool{
New: func() interface{} {
return make([]byte, 32*1024)
},
}

func (ghx *GitHTTPXfer) getInfoRefs(ctx Context) {
res, req, repoPath := ctx.Response(), ctx.Request(), ctx.RepoPath()

Expand Down

0 comments on commit 3f35dbe

Please sign in to comment.