mirror of
https://github.com/zrepl/zrepl.git
synced 2024-11-21 16:03:32 +01:00
rpc/dataconn: always close send stream returned from Sender.Send()
discovered while debugging #457
This commit is contained in:
parent
4f9b63aa09
commit
2c9fcd7c14
@ -172,6 +172,15 @@ func (s *Server) serveConnRequest(ctx context.Context, endpoint string, c *strea
|
||||
return
|
||||
}
|
||||
res, sendStream, handlerErr = s.h.Send(ctx, &req) // SHADOWING
|
||||
// ensure that we always close the sendStream
|
||||
if sendStream != nil {
|
||||
defer func() {
|
||||
err := sendStream.Close()
|
||||
if err != nil {
|
||||
s.log.WithError(err).Error("cannot close send stream")
|
||||
}
|
||||
}()
|
||||
}
|
||||
case EndpointRecv:
|
||||
var req pdu.ReceiveReq
|
||||
if err := proto.Unmarshal(reqStructured, &req); err != nil {
|
||||
@ -239,12 +248,9 @@ func (s *Server) serveConnRequest(ctx context.Context, endpoint string, c *strea
|
||||
|
||||
if sendStream != nil {
|
||||
err := c.SendStream(ctx, sendStream, ZFSStream)
|
||||
closeErr := sendStream.Close()
|
||||
if closeErr != nil {
|
||||
s.log.WithError(closeErr).Error("cannot close send stream")
|
||||
}
|
||||
if err != nil {
|
||||
s.log.WithError(err).Error("cannot write send stream")
|
||||
}
|
||||
// sendStream.Close() done via defer above
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user