Commit 7cdd4bc9 authored by Steven Allen's avatar Steven Allen
Browse files

Reset on error in basic_host

parent 1b9aa778
......@@ -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)
......
......@@ -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")
......
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