Commit 3f773ebd authored by Juan Batiz-Benet's avatar Juan Batiz-Benet

bitswap net: always close

parent cdefdb39
...@@ -97,23 +97,20 @@ func (bsnet *impl) Provide(ctx context.Context, k util.Key) error { ...@@ -97,23 +97,20 @@ func (bsnet *impl) Provide(ctx context.Context, k util.Key) error {
// handleNewStream receives a new stream from the network. // handleNewStream receives a new stream from the network.
func (bsnet *impl) handleNewStream(s inet.Stream) { func (bsnet *impl) handleNewStream(s inet.Stream) {
defer s.Close()
if bsnet.receiver == nil { if bsnet.receiver == nil {
return return
} }
go func() { received, err := bsmsg.FromNet(s)
defer s.Close() if err != nil {
go bsnet.receiver.ReceiveError(err)
received, err := bsmsg.FromNet(s) return
if err != nil { }
go bsnet.receiver.ReceiveError(err)
return
}
p := s.Conn().RemotePeer()
ctx := context.Background()
bsnet.receiver.ReceiveMessage(ctx, p, received)
}()
p := s.Conn().RemotePeer()
ctx := context.Background()
log.Debugf("bsnet handleNewStream from %s", s.Conn().RemotePeer())
bsnet.receiver.ReceiveMessage(ctx, p, received)
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment