Skip to content

Commit 8b4a5dd

Browse files
committed
fix(net): solve the problem of concurrent access to syncBlockToFetch object
1 parent e7c8d40 commit 8b4a5dd

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

framework/src/main/java/org/tron/core/net/service/sync/SyncService.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,9 @@ private void processSyncBlock(BlockCapsule block, PeerConnection peerConnection)
321321
}
322322

323323
for (PeerConnection peer : tronNetDelegate.getActivePeer()) {
324-
if (blockId.equals(peer.getSyncBlockToFetch().peek())) {
325-
peer.getSyncBlockToFetch().pop();
324+
BlockId bid = peer.getSyncBlockToFetch().peek();
325+
if (blockId.equals(bid)) {
326+
peer.getSyncBlockToFetch().remove(bid);
326327
if (flag) {
327328
peer.setBlockBothHave(blockId);
328329
if (peer.getSyncBlockToFetch().isEmpty() && peer.isFetchAble()) {

0 commit comments

Comments
 (0)