Skip to content

Commit

Permalink
fix dht repeated closing of stream
Browse files Browse the repository at this point in the history
  • Loading branch information
bysomeone committed May 24, 2024
1 parent cd672cb commit 35f6c82
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions system/p2p/dht/protocol/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,10 @@ func CloseStream(stream network.Stream) {
if stream == nil {
return
}
_ = stream.CloseWrite()
_ = stream.CloseRead()
go func() {
err := AwaitEOF(stream)
if err != nil {
//just log it because it dose not matter
log.Debug("CloseStream", "err", err, "protocol ID", stream.Protocol())
}
}()
err := stream.Close()
if err != nil {
log.Debug("CloseStream", "err", err, "protocol ID", stream.Protocol())
}
}

// AuthenticateMessage authenticates p2p message.
Expand Down Expand Up @@ -384,7 +379,8 @@ func AwaitEOF(s network.Stream) error {
_ = s.Reset()
return err
}
return s.Close()
_ = s.Close()
return nil
}

// migrated from github.com/multiformats/[email protected]: header.go
Expand Down

0 comments on commit 35f6c82

Please sign in to comment.