aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRustDesk <[email protected]>2022-10-04 14:54:08 +0800
committerGitHub <[email protected]>2022-10-04 14:54:08 +0800
commitfa2b42db7643a779398bdffe605e313c8e1085e3 (patch)
tree0098f845c6d7132be81a18f87f338ad4ef0cbe8c /src
parent85af668a4f746a8138cbc0d26e2eba66ab95cfa0 (diff)
parent099aaa6b5510db6678e61ab30ef7f0b193f7a36a (diff)
downloadrustdesk-server-fa2b42db7643a779398bdffe605e313c8e1085e3.tar.gz
rustdesk-server-fa2b42db7643a779398bdffe605e313c8e1085e3.zip
Merge pull request #122 from fufesou/peer_online_state
query_onlines: trivial refactor
Diffstat (limited to 'src')
-rw-r--r--src/rendezvous_server.rs14
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;
}