From 1235edb23925b0653f028cc60d4e9966ed055380 Mon Sep 17 00:00:00 2001 From: rustdesk Date: Fri, 29 Apr 2022 19:40:53 +0800 Subject: [PATCH] found one blank cm, still not find reason --- src/ui/cm.rs | 6 +++++- src/ui/cm.tis | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ui/cm.rs b/src/ui/cm.rs index 17c0cf34b..cb6ebc171 100644 --- a/src/ui/cm.rs +++ b/src/ui/cm.rs @@ -359,6 +359,7 @@ async fn start_ipc(cm: ConnectionManager) { while let Some(result) = incoming.next().await { match result { Ok(stream) => { + log::debug!("Got new connection"); let mut stream = Connection::new(stream); let cm = cm.clone(); let tx_file = tx_file.clone(); @@ -377,6 +378,7 @@ async fn start_ipc(cm: ConnectionManager) { Ok(Some(data)) => { match data { Data::Login{id, is_file_transfer, port_forward, peer_id, name, authorized, keyboard, clipboard, audio, file, file_transfer_enabled} => { + log::debug!("conn_id: {}", id); conn_id = id; tx_file.send(ClipboardFileData::Enable((id, file_transfer_enabled))).ok(); cm.add_connection(id, is_file_transfer, port_forward, peer_id, name, authorized, keyboard, clipboard, audio, file, tx.clone()); @@ -395,7 +397,9 @@ async fn start_ipc(cm: ConnectionManager) { } } Some(data) = rx.recv() => { - allow_err!(stream.send(&data).await); + if stream.send(&data).await.is_err() { + break; + } } } } diff --git a/src/ui/cm.tis b/src/ui/cm.tis index 4cf306e50..ab3f22f12 100644 --- a/src/ui/cm.tis +++ b/src/ui/cm.tis @@ -290,6 +290,7 @@ handler.removeConnection = function(id) { connections.map(function(c, idx) { if (c.id == id) i = idx; }); + if (i < 0) return; connections.splice(i, 1); if (connections.length == 0) { handler.exit();