Commit bf637bca authored by Jeromy's avatar Jeromy

fix minor data race in bitswap

parent a499bbac
...@@ -287,8 +287,10 @@ func (bs *Bitswap) ReceiveMessage(ctx context.Context, p peer.ID, incoming bsmsg ...@@ -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 {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment