mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-30 18:13:54 +08:00
Merge pull request #1281 from ipfs/fix/bs-race
fix minor data race in bitswap
This commit is contained in:
@ -287,8 +287,10 @@ func (bs *Bitswap) ReceiveMessage(ctx context.Context, p peer.ID, incoming bsmsg
|
|||||||
if has, err := bs.blockstore.Has(block.Key()); err == nil && has {
|
if has, err := bs.blockstore.Has(block.Key()); err == nil && has {
|
||||||
bs.dupBlocksRecvd++
|
bs.dupBlocksRecvd++
|
||||||
}
|
}
|
||||||
|
brecvd := bs.blocksRecvd
|
||||||
|
bdup := bs.dupBlocksRecvd
|
||||||
bs.counterLk.Unlock()
|
bs.counterLk.Unlock()
|
||||||
log.Infof("got block %s from %s (%d,%d)", block, p, bs.blocksRecvd, bs.dupBlocksRecvd)
|
log.Infof("got block %s from %s (%d,%d)", block, p, brecvd, bdup)
|
||||||
|
|
||||||
hasBlockCtx, cancel := context.WithTimeout(ctx, hasBlockTimeout)
|
hasBlockCtx, cancel := context.WithTimeout(ctx, hasBlockTimeout)
|
||||||
if err := bs.HasBlock(hasBlockCtx, block); err != nil {
|
if err := bs.HasBlock(hasBlockCtx, block); err != nil {
|
||||||
|
Reference in New Issue
Block a user