From 65512193ccf97e6fd9b22c9953086a1ea3ad967a Mon Sep 17 00:00:00 2001 From: Lucas Molas Date: Wed, 5 Aug 2020 19:40:00 -0300 Subject: [PATCH] clear deadline in server --- chain/blocksync/client.go | 6 ++---- chain/blocksync/server.go | 2 ++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/chain/blocksync/client.go b/chain/blocksync/client.go index cf67b4802..feee7015c 100644 --- a/chain/blocksync/client.go +++ b/chain/blocksync/client.go @@ -378,14 +378,12 @@ func (client *BlockSync) sendRequestToPeer( _ = stream.SetWriteDeadline(time.Now().Add(WRITE_REQ_DEADLINE)) if err := cborutil.WriteCborRPC(stream, req); err != nil { _ = stream.SetWriteDeadline(time.Time{}) - // FIXME: What's the point of setting a blank deadline that won't time out? - // Is this our way of clearing the old one? client.peerTracker.logFailure(peer, build.Clock.Since(connectionStart)) // FIXME: Should we also remove peer here? return nil, err } - // FIXME: Same, why are we doing this again here? - _ = stream.SetWriteDeadline(time.Time{}) + _ = stream.SetWriteDeadline(time.Time{}) // clear deadline // FIXME: Needs + // its own API (https://github.com/libp2p/go-libp2p-core/issues/162). // Read response. var res Response diff --git a/chain/blocksync/server.go b/chain/blocksync/server.go index 9aefbb648..32ed4a16f 100644 --- a/chain/blocksync/server.go +++ b/chain/blocksync/server.go @@ -71,10 +71,12 @@ func (server *BlockSyncService) HandleStream(stream inet.Stream) { _ = stream.SetDeadline(time.Now().Add(WRITE_RES_DEADLINE)) if err := cborutil.WriteCborRPC(stream, resp); err != nil { + _ = stream.SetDeadline(time.Time{}) log.Warnw("failed to write back response for handle stream", "err", err, "peer", stream.Conn().RemotePeer()) return } + _ = stream.SetDeadline(time.Time{}) } // Validate and service the request. We return either a protocol