Skip to content

Commit

Permalink
Merge pull request #5254 from turuslan/fix/chainxchg-buffered
Browse files Browse the repository at this point in the history
Chainxchg write response timeout
  • Loading branch information
magik6k authored Jan 5, 2021
2 parents ab529f4 + f9aca39 commit a15080b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion chain/exchange/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ func (s *server) HandleStream(stream inet.Stream) {
}

_ = stream.SetDeadline(time.Now().Add(WriteResDeadline))
if err := cborutil.WriteCborRPC(stream, resp); err != nil {
buffered := bufio.NewWriter(stream)
if err = cborutil.WriteCborRPC(buffered, resp); err == nil {
err = buffered.Flush()
}
if err != nil {
_ = stream.SetDeadline(time.Time{})
log.Warnw("failed to write back response for handle stream",
"err", err, "peer", stream.Conn().RemotePeer())
Expand Down

0 comments on commit a15080b

Please sign in to comment.