Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-workhorse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-workhorse
Commits
b0b91eb5
Commit
b0b91eb5
authored
Apr 25, 2017
by
Nick Thomas
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'gitaly-cancel-grpc' into 'master'
Always cancel gRPC stream contexts See merge request !158
parents
fe8688e0
bc340433
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
6 deletions
+16
-6
internal/git/info-refs.go
internal/git/info-refs.go
+5
-1
internal/gitaly/smarthttp.go
internal/gitaly/smarthttp.go
+11
-5
No files found.
internal/git/info-refs.go
View file @
b0b91eb5
...
...
@@ -7,6 +7,8 @@ import (
"gitlab.com/gitlab-org/gitlab-workhorse/internal/api"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/gitaly"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
"golang.org/x/net/context"
)
func
GetInfoRefsHandler
(
a
*
api
.
API
)
http
.
Handler
{
...
...
@@ -67,7 +69,9 @@ func handleGetInfoRefsWithGitaly(w http.ResponseWriter, a *api.Response, rpc str
return
fmt
.
Errorf
(
"GetInfoRefsHandler: %v"
,
err
)
}
infoRefsResponseWriter
,
err
:=
smarthttp
.
InfoRefsResponseWriterTo
(
&
a
.
Repository
,
rpc
)
ctx
,
cancelFunc
:=
context
.
WithCancel
(
context
.
Background
())
defer
cancelFunc
()
infoRefsResponseWriter
,
err
:=
smarthttp
.
InfoRefsResponseWriterTo
(
ctx
,
&
a
.
Repository
,
rpc
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"GetInfoRefsHandler: %v"
,
err
)
}
...
...
internal/gitaly/smarthttp.go
View file @
b0b91eb5
...
...
@@ -25,16 +25,16 @@ type receivePackWriter struct {
const
sendChunkSize
=
16384
func
(
client
*
SmartHTTPClient
)
InfoRefsResponseWriterTo
(
repo
*
pb
.
Repository
,
rpc
string
)
(
io
.
WriterTo
,
error
)
{
func
(
client
*
SmartHTTPClient
)
InfoRefsResponseWriterTo
(
ctx
context
.
Context
,
repo
*
pb
.
Repository
,
rpc
string
)
(
io
.
WriterTo
,
error
)
{
rpcRequest
:=
&
pb
.
InfoRefsRequest
{
Repository
:
repo
}
var
c
pbhelper
.
InfoRefsClient
var
err
error
switch
rpc
{
case
"git-upload-pack"
:
c
,
err
=
client
.
InfoRefsUploadPack
(
c
ontext
.
Background
()
,
rpcRequest
)
c
,
err
=
client
.
InfoRefsUploadPack
(
c
tx
,
rpcRequest
)
case
"git-receive-pack"
:
c
,
err
=
client
.
InfoRefsReceivePack
(
c
ontext
.
Background
()
,
rpcRequest
)
c
,
err
=
client
.
InfoRefsReceivePack
(
c
tx
,
rpcRequest
)
default
:
return
nil
,
fmt
.
Errorf
(
"InfoRefsResponseWriterTo: Unsupported RPC: %q"
,
rpc
)
}
...
...
@@ -47,7 +47,10 @@ func (client *SmartHTTPClient) InfoRefsResponseWriterTo(repo *pb.Repository, rpc
}
func
(
client
*
SmartHTTPClient
)
ReceivePack
(
repo
*
pb
.
Repository
,
GlId
string
,
clientRequest
io
.
Reader
,
clientResponse
io
.
Writer
)
error
{
stream
,
err
:=
client
.
PostReceivePack
(
context
.
Background
())
ctx
,
cancelFunc
:=
context
.
WithCancel
(
context
.
Background
())
defer
cancelFunc
()
stream
,
err
:=
client
.
PostReceivePack
(
ctx
)
if
err
!=
nil
{
return
err
}
...
...
@@ -82,7 +85,10 @@ func (client *SmartHTTPClient) ReceivePack(repo *pb.Repository, GlId string, cli
}
func
(
client
*
SmartHTTPClient
)
UploadPack
(
repo
*
pb
.
Repository
,
clientRequest
io
.
Reader
,
clientResponse
io
.
Writer
)
error
{
stream
,
err
:=
client
.
PostUploadPack
(
context
.
Background
())
ctx
,
cancelFunc
:=
context
.
WithCancel
(
context
.
Background
())
defer
cancelFunc
()
stream
,
err
:=
client
.
PostUploadPack
(
ctx
)
if
err
!=
nil
{
return
err
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment