diff options
author | fufesou <[email protected]> | 2022-10-03 20:52:44 +0800 |
---|---|---|
committer | fufesou <[email protected]> | 2022-10-04 13:09:56 +0800 |
commit | 099aaa6b5510db6678e61ab30ef7f0b193f7a36a (patch) | |
tree | 8955f5d8c8ecbfa7d30d9aa7c0315469b1f8d879 /src | |
parent | f7fc45a3d2280a9026858a8be4157eb3a1b301c8 (diff) | |
download | rustdesk-server-099aaa6b5510db6678e61ab30ef7f0b193f7a36a.tar.gz rustdesk-server-099aaa6b5510db6678e61ab30ef7f0b193f7a36a.zip |
query_onlines: trivial refactor
Signed-off-by: fufesou <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/rendezvous_server.rs | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/rendezvous_server.rs b/src/rendezvous_server.rs index b93e04f..9cea15d 100644 --- a/src/rendezvous_server.rs +++ b/src/rendezvous_server.rs @@ -759,15 +759,11 @@ impl RendezvousServer { ) -> ResultType<()> { let mut states = BytesMut::zeroed((peers.len() + 7) / 8); for i in 0..peers.len() { - let peer_id = &peers[i]; - // bytes index from left to right - let states_idx = i / 8; - let bit_idx = 7 - i % 8; - if let Some(peer) = self.pm.get_in_memory(&peer_id).await { - let (elapsed, _) = { - let r = peer.read().await; - (r.last_reg_time.elapsed().as_millis() as i32, r.socket_addr) - }; + if let Some(peer) = self.pm.get_in_memory(&peers[i]).await { + let elapsed = peer.read().await.last_reg_time.elapsed().as_millis() as i32; + // bytes index from left to right + let states_idx = i / 8; + let bit_idx = 7 - i % 8; if elapsed < REG_TIMEOUT { states[states_idx] |= 0x01 << bit_idx; } |