Skip to content

Commit

Permalink
address potential deadlock in mobilecoind (#3986)
Browse files Browse the repository at this point in the history
  • Loading branch information
eranrund authored May 20, 2024
1 parent ff438a5 commit b457720
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions mobilecoind/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2435,8 +2435,14 @@ impl<T: BlockchainConnection + UserTxConnection + 'static, FPR: FogPubkeyResolve
}
let local_block_index = num_blocks - 1;

// Get LastBlockInfo from our peers
let block_infos = self.get_last_block_infos();
// Get LastBlockInfo from our peers - this is the same code as
// `self.get_last_block_infos` but avoids locking the same rwlock twice from the same thread (see potential deadlock scenario example in https://doc.rust-lang.org/std/sync/struct.RwLock.html).
let block_infos = network_state
.peer_to_block_info()
.values()
.cloned()
.collect::<Vec<_>>();

// choose the block info which is latest in terms of block index (we may be
// isolated from some of the nodes)
let last_block_info = block_infos
Expand Down

0 comments on commit b457720

Please sign in to comment.