Skip to content

Commit

Permalink
fix(server_core): 🐛 Fix server locking the session unnecessarily (#2619)
Browse files Browse the repository at this point in the history
  • Loading branch information
zmerp authored Jan 15, 2025
1 parent 4f7c9e9 commit 23ce975
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions alvr/server_core/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,14 @@ pub fn handshake_loop(ctx: Arc<ConnectionContext>, lifecycle_state: Arc<RwLock<L
dbg_connection!("handshake_loop: Try connect to wired device");

let mut wired_client_ips = HashMap::new();
if let Some((client_hostname, _)) =
SESSION_MANAGER
.read()
.client_list()
.iter()
.find(|(hostname, info)| {
info.connection_state == ConnectionState::Disconnected
&& hostname.as_str() == WIRED_CLIENT_HOSTNAME
})
if SESSION_MANAGER
.read()
.client_list()
.iter()
.any(|(hostname, info)| {
info.connection_state == ConnectionState::Disconnected
&& hostname.as_str() == WIRED_CLIENT_HOSTNAME
})
{
// Make sure the wired connection is created once and kept alive
let wired_connection = if let Some(connection) = &wired_connection {
Expand Down Expand Up @@ -320,7 +319,7 @@ pub fn handshake_loop(ctx: Arc<ConnectionContext>, lifecycle_state: Arc<RwLock<L
}

let client_ip = IpAddr::V4(Ipv4Addr::LOCALHOST);
wired_client_ips.insert(client_ip, client_hostname.to_owned());
wired_client_ips.insert(client_ip, WIRED_CLIENT_HOSTNAME.to_owned());
}

if !wired_client_ips.is_empty()
Expand Down

0 comments on commit 23ce975

Please sign in to comment.