From df55566538f4177b722434ca7e0c60ac386b706b Mon Sep 17 00:00:00 2001 From: LexLuthr Date: Mon, 20 May 2024 12:19:38 +0530 Subject: [PATCH] close empty streams --- network/libp2p_impl.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/network/libp2p_impl.go b/network/libp2p_impl.go index d35a460e..b76f0498 100644 --- a/network/libp2p_impl.go +++ b/network/libp2p_impl.go @@ -231,6 +231,7 @@ func (gsnet *libp2pGraphSyncNetwork) handleNewStream(s network.Stream) { reader := msgio.NewVarintReaderSize(s, network.MessageSizeMax) for { p = s.Conn().RemotePeer() + _ = s.SetReadDeadline(time.Now().Add(time.Second * 10)) received, err := gsnet.messageHandlerSelector.Select(s.Protocol()).FromMsgReader(s.Conn().RemotePeer(), reader) if err != nil { @@ -239,8 +240,10 @@ func (gsnet *libp2pGraphSyncNetwork) handleNewStream(s network.Stream) { go gsnet.receiver.ReceiveError(p, err) log.Debugf("graphsync net handleNewStream from %s error: %s", s.Conn().RemotePeer(), err) } + _ = s.SetReadDeadline(time.Time{}) return } + _ = s.SetReadDeadline(time.Time{}) ctx := context.Background() log.Debugf("graphsync net handleNewStream from %s", s.Conn().RemotePeer())