Skip to content

Commit

Permalink
Merge pull request #463 from harmony-ek/fix_stream_leak
Browse files Browse the repository at this point in the history
Fix stream leak
  • Loading branch information
Eugene Kim committed Feb 16, 2019
2 parents b875062 + f96ad97 commit 844bb37
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions p2p/host/hostv2/hostv2.go
Expand Up @@ -222,6 +222,11 @@ func (host *HostV2) SendMessage(p p2p.Peer, message []byte) error {
"protocolID", ProtocolID, "error", err)
return p2p.ErrNewStream
}
defer func() {
if err := s.Close(); err != nil {
logger.Warn("cannot close stream", "error", err)
}
}()
if nw, err := s.Write(message); err != nil {
logger.Error("Write() failed", "peerID", p.PeerID,
"protocolID", ProtocolID, "error", err)
Expand Down

0 comments on commit 844bb37

Please sign in to comment.