Skip to content

Commit

Permalink
Merge pull request ipfs/go-bitswap#508 from ipfs/fix/disconnect-data-…
Browse files Browse the repository at this point in the history
…race

fix(decision): fix a datarace on disconnect

This commit was moved from ipfs/go-bitswap@5f2fd63
  • Loading branch information
Stebalien authored Jun 24, 2021
2 parents ec8d143 + ad9db9b commit 1f14023
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion bitswap/internal/decision/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,11 @@ func (e *Engine) PeerDisconnected(p peer.ID) {

ledger, ok := e.ledgerMap[p]
if ok {
for _, entry := range ledger.Entries() {
ledger.lk.RLock()
entries := ledger.Entries()
ledger.lk.RUnlock()

for _, entry := range entries {
e.peerLedger.CancelWant(p, entry.Cid)
}
}
Expand Down

0 comments on commit 1f14023

Please sign in to comment.