Skip to content

Commit

Permalink
discovery: remove possible deadlock when reading state
Browse files Browse the repository at this point in the history
Eliminate a possible deadlock due to trying to aquire the read lock on
State while already holding a read lock.
  • Loading branch information
bmwill committed Dec 23, 2022
1 parent e425af0 commit e42f5d6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion crates/sui-network/src/discovery/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ impl DiscoveryEventLoop {
.collect::<Vec<_>>();

// No need to connect to any more peers if we're already connected to a bunch
let number_of_connections = self.state.read().unwrap().connected_peers.len();
let number_of_connections = state.connected_peers.len();
let number_to_dial = std::cmp::min(
eligible.len(),
MAX_NUMBER_OF_CONNECTIONS.saturating_sub(number_of_connections),
Expand Down

0 comments on commit e42f5d6

Please sign in to comment.