Skip to content

Commit ec48b16

Browse files
authored
Merge pull request #5832 from zeusoo001/f-sove-access-problem-syncblock
fix(net): solve the problem of concurrent access to syncBlockToFetch object
2 parents 6949480 + 8b4a5dd commit ec48b16

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)