From 8ed926d219174f3d057ac1ff158aab6085560f1a Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 18 Jul 2018 09:56:25 -0700 Subject: [PATCH] when sending blocks in bitswap, close streams asynchronously Otherwise, we tie up the bitswap worker until the other side responds with an EOF. fixes #5247 related to https://github.com/libp2p/go-libp2p-net/issues/28 License: MIT Signed-off-by: Steven Allen --- network/ipfs_impl.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/network/ipfs_impl.go b/network/ipfs_impl.go index efeb693..1b6e389 100644 --- a/network/ipfs_impl.go +++ b/network/ipfs_impl.go @@ -123,9 +123,10 @@ func (bsnet *impl) SendMessage( s.Reset() return err } - // Yes, return this error. We have no reason to believe that the block - // was actually *sent* unless we see the EOF. - return inet.FullClose(s) + // TODO(https://github.com/libp2p/go-libp2p-net/issues/28): Avoid this goroutine. + go inet.AwaitEOF(s) + return s.Close() + } func (bsnet *impl) SetDelegate(r Receiver) { -- GitLab