diff --git a/p2p/host/basic/basic_host.go b/p2p/host/basic/basic_host.go index 3f0f11356e365c6f5cfccd564a21c33f8ae677fa..3a7874b3e7a2af28b4d0bfbc04b7e80b0823e30e 100644 --- a/p2p/host/basic/basic_host.go +++ b/p2p/host/basic/basic_host.go @@ -240,7 +240,7 @@ func (h *BasicHost) newStreamHandler(s inet.Stream) { if h.negtimeout > 0 { if err := s.SetDeadline(time.Now().Add(h.negtimeout)); err != nil { log.Error("setting stream deadline: ", err) - s.Close() + s.Reset() return } } @@ -257,7 +257,7 @@ func (h *BasicHost) newStreamHandler(s inet.Stream) { } else { log.Warning("protocol mux failed: %s (took %s)", err, took) } - s.Close() + s.Reset() return } @@ -269,7 +269,7 @@ func (h *BasicHost) newStreamHandler(s inet.Stream) { if h.negtimeout > 0 { if err := s.SetDeadline(time.Time{}); err != nil { log.Error("resetting stream deadline: ", err) - s.Close() + s.Reset() return } } @@ -364,7 +364,7 @@ func (h *BasicHost) NewStream(ctx context.Context, p peer.ID, pids ...protocol.I selected, err := msmux.SelectOneOf(protoStrs, s) if err != nil { - s.Close() + s.Reset() return nil, err } selpid := protocol.ID(selected) diff --git a/p2p/host/basic/basic_host_test.go b/p2p/host/basic/basic_host_test.go index af4a8306b7a0f93e0d855308992ff44fd78e959c..4c14934507ef557f8d8a982acf62ff12077973cf 100644 --- a/p2p/host/basic/basic_host_test.go +++ b/p2p/host/basic/basic_host_test.go @@ -180,7 +180,7 @@ func TestHostProtoMismatch(t *testing.T) { h1.SetStreamHandler("/super", func(s inet.Stream) { t.Error("shouldnt get here") - s.Close() + s.Reset() }) _, err := h2.NewStream(ctx, h1.ID(), "/foo", "/bar", "/baz/1.0.0")