client: reset encoders between uses

According to go/codec's docs, Reset(...) should be called on
Decoders/Encoders before reuse:

https://godoc.org/github.com/ugorji/go/codec

I could find no evidence that *not* calling Reset() caused bugs, but
might as well do what the docs say?
This commit is contained in:
Michael Schurter
2018-04-30 16:07:23 -07:00
parent 41f05dc2c4
commit a7c71c1cdc
2 changed files with 7 additions and 2 deletions

View File

@@ -361,6 +361,7 @@ func (s *HTTPServer) fsStreamImpl(resp http.ResponseWriter,
cancel()
return
}
encoder.Reset(httpPipe)
for {
select {
@@ -377,6 +378,7 @@ func (s *HTTPServer) fsStreamImpl(resp http.ResponseWriter,
cancel()
return
}
decoder.Reset(httpPipe)
if err := res.Error; err != nil {
if err.Code != nil {