Commit 23286417 authored by Jeromy's avatar Jeromy
Browse files

make sure to always close streams when youre done with them

parent adfb6b8f
...@@ -117,6 +117,7 @@ func (h *BasicHost) newStreamHandler(s inet.Stream) { ...@@ -117,6 +117,7 @@ func (h *BasicHost) newStreamHandler(s inet.Stream) {
} else { } else {
log.Warning("protocol mux failed: %s (took %s)", err, took) log.Warning("protocol mux failed: %s (took %s)", err, took)
} }
s.Close()
return return
} }
s.SetProtocol(protocol.ID(protoID)) s.SetProtocol(protocol.ID(protoID))
......
...@@ -87,6 +87,7 @@ func (ids *IDService) IdentifyConn(c inet.Conn) { ...@@ -87,6 +87,7 @@ func (ids *IDService) IdentifyConn(c inet.Conn) {
c.Close() c.Close()
return return
} }
defer s.Close()
s.SetProtocol(ID) s.SetProtocol(ID)
...@@ -97,7 +98,6 @@ func (ids *IDService) IdentifyConn(c inet.Conn) { ...@@ -97,7 +98,6 @@ func (ids *IDService) IdentifyConn(c inet.Conn) {
if err := msmux.SelectProtoOrFail(ID, s); err != nil { if err := msmux.SelectProtoOrFail(ID, s); err != nil {
log.Debugf("error writing stream header for %s", ID) log.Debugf("error writing stream header for %s", ID)
log.Event(context.TODO(), "IdentifyOpenFailed", c.RemotePeer()) log.Event(context.TODO(), "IdentifyOpenFailed", c.RemotePeer())
s.Close()
return return
} }
......
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