diff --git a/p2p/host/basic/basic_host.go b/p2p/host/basic/basic_host.go index 355f5490aca8043d047ae612c0a082bd44ee49b8..d0c15752be50cef1e2adad7bc6503b2c416986a4 100644 --- a/p2p/host/basic/basic_host.go +++ b/p2p/host/basic/basic_host.go @@ -117,6 +117,7 @@ func (h *BasicHost) newStreamHandler(s inet.Stream) { } else { log.Warning("protocol mux failed: %s (took %s)", err, took) } + s.Close() return } s.SetProtocol(protocol.ID(protoID)) diff --git a/p2p/protocol/identify/id.go b/p2p/protocol/identify/id.go index 36e08b2279d6f2267802eab5d8caceadabb91297..baffc5afaf06a54d31a90c8eb433f2feabf62c39 100644 --- a/p2p/protocol/identify/id.go +++ b/p2p/protocol/identify/id.go @@ -87,6 +87,7 @@ func (ids *IDService) IdentifyConn(c inet.Conn) { c.Close() return } + defer s.Close() s.SetProtocol(ID) @@ -97,7 +98,6 @@ func (ids *IDService) IdentifyConn(c inet.Conn) { if err := msmux.SelectProtoOrFail(ID, s); err != nil { log.Debugf("error writing stream header for %s", ID) log.Event(context.TODO(), "IdentifyOpenFailed", c.RemotePeer()) - s.Close() return }