Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Nomad
Commits
63dad441
Commit
63dad441
authored
7 years ago
by
Michael Schurter
Browse files
Options
Download
Email Patches
Plain Diff
client: ensure cancel is always called when func exits
parent
564854dd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
command/agent/fs_endpoint.go
+2
-5
command/agent/fs_endpoint.go
with
2 additions
and
5 deletions
+2
-5
command/agent/fs_endpoint.go
+
2
-
5
View file @
63dad441
...
...
@@ -356,10 +356,11 @@ func (s *HTTPServer) fsStreamImpl(resp http.ResponseWriter,
// Create a channel that decodes the results
errCh
:=
make
(
chan
HTTPCodedError
)
go
func
()
{
defer
cancel
()
// Send the request
if
err
:=
encoder
.
Encode
(
args
);
err
!=
nil
{
errCh
<-
CodedError
(
500
,
err
.
Error
())
cancel
()
return
}
encoder
.
Reset
(
httpPipe
)
...
...
@@ -368,7 +369,6 @@ func (s *HTTPServer) fsStreamImpl(resp http.ResponseWriter,
select
{
case
<-
ctx
.
Done
()
:
errCh
<-
nil
cancel
()
return
default
:
}
...
...
@@ -376,7 +376,6 @@ func (s *HTTPServer) fsStreamImpl(resp http.ResponseWriter,
var
res
cstructs
.
StreamErrWrapper
if
err
:=
decoder
.
Decode
(
&
res
);
err
!=
nil
{
errCh
<-
CodedError
(
500
,
err
.
Error
())
cancel
()
return
}
decoder
.
Reset
(
httpPipe
)
...
...
@@ -384,14 +383,12 @@ func (s *HTTPServer) fsStreamImpl(resp http.ResponseWriter,
if
err
:=
res
.
Error
;
err
!=
nil
{
if
err
.
Code
!=
nil
{
errCh
<-
CodedError
(
int
(
*
err
.
Code
),
err
.
Error
())
cancel
()
return
}
}
if
_
,
err
:=
io
.
Copy
(
output
,
bytes
.
NewBuffer
(
res
.
Payload
));
err
!=
nil
{
errCh
<-
CodedError
(
500
,
err
.
Error
())
cancel
()
return
}
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
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