From 93d5c2e48929cf45c5c92b14496201de449e9e28 Mon Sep 17 00:00:00 2001 From: Marco Munizaga Date: Thu, 16 May 2024 07:28:56 -0700 Subject: [PATCH] fix: Set missing deadlines (#2794) * Set missing deadlines * Revert changes to gostream. Not the right place --- p2p/protocol/circuitv2/client/handlers.go | 2 ++ p2p/protocol/circuitv2/relay/relay.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/p2p/protocol/circuitv2/client/handlers.go b/p2p/protocol/circuitv2/client/handlers.go index 9c36de0e8..389f0e44b 100644 --- a/p2p/protocol/circuitv2/client/handlers.go +++ b/p2p/protocol/circuitv2/client/handlers.go @@ -22,6 +22,8 @@ func (c *Client) handleStreamV2(s network.Stream) { defer rd.Close() writeResponse := func(status pbv2.Status) error { + s.SetWriteDeadline(time.Now().Add(StreamTimeout)) + defer s.SetWriteDeadline(time.Time{}) wr := util.NewDelimitedWriter(s) var msg pbv2.StopMessage diff --git a/p2p/protocol/circuitv2/relay/relay.go b/p2p/protocol/circuitv2/relay/relay.go index 0ad36168f..1629a6d1a 100644 --- a/p2p/protocol/circuitv2/relay/relay.go +++ b/p2p/protocol/circuitv2/relay/relay.go @@ -556,6 +556,8 @@ func (r *Relay) handleError(s network.Stream, status pbv2.Status) { } func (r *Relay) writeResponse(s network.Stream, status pbv2.Status, rsvp *pbv2.Reservation, limit *pbv2.Limit) error { + s.SetWriteDeadline(time.Now().Add(StreamTimeout)) + defer s.SetWriteDeadline(time.Time{}) wr := util.NewDelimitedWriter(s) var msg pbv2.HopMessage