Skip to content

Commit 53988d7

Browse files
author
yxq
committed
fix: libp2p stream leak
1 parent 4dad050 commit 53988d7

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

system/p2p/dht/protocol/p2pstore/store.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func (p *Protocol) initLocalChunkInfoMap() {
120120
start := time.Now()
121121
records, err := p.getChunkRecordFromBlockchain(&types.ReqChunkRecords{Start: 0, End: 0})
122122
if err != nil {
123-
panic(err)
123+
return
124124
}
125125
if records == nil || len(records.Infos) != 1 {
126126
panic("invalid record")

system/p2p/dht/protocol/wrapper.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ func CloseStream(stream network.Stream) {
5252
return
5353
}
5454
_ = stream.CloseWrite()
55+
_ = stream.CloseRead()
5556
go func() {
5657
err := AwaitEOF(stream)
5758
if err != nil {
@@ -349,5 +350,5 @@ func AwaitEOF(s network.Stream) error {
349350
_ = s.Reset()
350351
return err
351352
}
352-
return nil
353+
return s.Close()
353354
}

0 commit comments

Comments
 (0)