Merge pull request #1879 from fufesou/fix_win_crash

fix: win remote and file transfer , simultaneous connection
This commit is contained in:
RustDesk 2022-10-31 10:21:38 +08:00 committed by GitHub
commit fc695fd453
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 32 additions and 20 deletions

View File

@ -1,5 +1,5 @@
use crate::client::{ use crate::client::{
Client, CodecFormat, FileManager, MediaData, MediaSender, QualityStatus, MILLI1, SEC30, Client, CodecFormat, MediaData, MediaSender, QualityStatus, MILLI1, SEC30,
SERVER_CLIPBOARD_ENABLED, SERVER_FILE_TRANSFER_ENABLED, SERVER_KEYBOARD_ENABLED, SERVER_CLIPBOARD_ENABLED, SERVER_FILE_TRANSFER_ENABLED, SERVER_KEYBOARD_ENABLED,
}; };
use crate::common; use crate::common;
@ -15,7 +15,7 @@ use crate::{client::Data, client::Interface};
use hbb_common::config::{PeerConfig, TransferSerde}; use hbb_common::config::{PeerConfig, TransferSerde};
use hbb_common::fs::{ use hbb_common::fs::{
can_enable_overwrite_detection, get_job, get_string, new_send_confirm, DigestCheckResult, can_enable_overwrite_detection, get_job, get_string, new_send_confirm, DigestCheckResult,
RemoveJobMeta, TransferJobMeta, RemoveJobMeta,
}; };
use hbb_common::message_proto::permission_info::Permission; use hbb_common::message_proto::permission_info::Permission;
use hbb_common::protobuf::Message as _; use hbb_common::protobuf::Message as _;
@ -23,6 +23,7 @@ use hbb_common::rendezvous_proto::ConnType;
use hbb_common::tokio::{ use hbb_common::tokio::{
self, self,
sync::mpsc, sync::mpsc,
sync::Mutex as TokioMutex,
time::{self, Duration, Instant, Interval}, time::{self, Duration, Instant, Interval},
}; };
use hbb_common::{ use hbb_common::{
@ -113,15 +114,23 @@ impl<T: InvokeUiSession> Remote<T> {
// just build for now // just build for now
#[cfg(not(windows))] #[cfg(not(windows))]
let (_tx_holder, mut rx_clip_client) = mpsc::unbounded_channel::<i32>(); let (_tx_holder, mut rx_clip_client) = mpsc::unbounded_channel::<i32>();
#[cfg(windows)] #[cfg(windows)]
let (client_conn_id, rx_clip_client1) = let (_tx_holder, rx) = mpsc::unbounded_channel();
clipboard::get_rx_cliprdr_client(&self.handler.id);
#[cfg(windows)] #[cfg(windows)]
let mut rx_clip_client = rx_clip_client1.lock().await; let mut rx_clip_client_lock = Arc::new(TokioMutex::new(rx));
#[cfg(windows)] #[cfg(windows)]
{ {
self.client_conn_id = client_conn_id; let is_conn_not_default = self.handler.is_file_transfer()
|| self.handler.is_port_forward()
|| self.handler.is_rdp();
if !is_conn_not_default {
(self.client_conn_id, rx_clip_client_lock) =
clipboard::get_rx_cliprdr_client(&self.handler.id);
};
} }
#[cfg(windows)]
let mut rx_clip_client = rx_clip_client_lock.lock().await;
let mut status_timer = time::interval(Duration::new(1, 0)); let mut status_timer = time::interval(Duration::new(1, 0));

View File

@ -1,5 +1,4 @@
use std::{ use std::{
collections::HashMap,
future::Future, future::Future,
sync::{Arc, Mutex}, sync::{Arc, Mutex},
}; };

View File

@ -418,6 +418,7 @@ pub fn session_start_(id: &str, event_stream: StreamSink<EventToUI>) -> ResultTy
pub mod connection_manager { pub mod connection_manager {
use std::collections::HashMap; use std::collections::HashMap;
#[cfg(any(target_os = "android"))]
use hbb_common::log; use hbb_common::log;
#[cfg(any(target_os = "android"))] #[cfg(any(target_os = "android"))]
use scrap::android::call_main_service_set_by_name; use scrap::android::call_main_service_set_by_name;

View File

@ -7,13 +7,14 @@ use std::{
use flutter_rust_bridge::{StreamSink, SyncReturn, ZeroCopyBuffer}; use flutter_rust_bridge::{StreamSink, SyncReturn, ZeroCopyBuffer};
use serde_json::json; use serde_json::json;
use hbb_common::ResultType;
use hbb_common::{ use hbb_common::{
config::{self, LocalConfig, PeerConfig, ONLINE}, config::{self, LocalConfig, PeerConfig, ONLINE},
fs, log, fs, log,
}; };
use hbb_common::{message_proto::Hash, ResultType};
use crate::flutter::{self, SESSIONS}; use crate::flutter::{self, SESSIONS};
#[cfg(target_os = "android")]
use crate::start_server; use crate::start_server;
use crate::ui_interface::{self, *}; use crate::ui_interface::{self, *};
use crate::{ use crate::{
@ -362,7 +363,7 @@ pub fn session_create_dir(id: String, act_id: i32, path: String, is_remote: bool
} }
} }
pub fn session_read_local_dir_sync(id: String, path: String, show_hidden: bool) -> String { pub fn session_read_local_dir_sync(_id: String, path: String, show_hidden: bool) -> String {
if let Ok(fd) = fs::read_dir(&fs::get_path(&path), show_hidden) { if let Ok(fd) = fs::read_dir(&fs::get_path(&path), show_hidden) {
return make_fd_to_json(fd.id, path, &fd.entries); return make_fd_to_json(fd.id, path, &fd.entries);
} }

View File

@ -725,7 +725,7 @@ fn legacy_keyboard_mode(evt: &KeyEvent) {
// disable numlock if press home etc when numlock is on, // disable numlock if press home etc when numlock is on,
// because we will get numpad value (7,8,9 etc) if not // because we will get numpad value (7,8,9 etc) if not
#[cfg(windows)] #[cfg(windows)]
let mut disable_numlock = false; let mut _disable_numlock = false;
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
en.reset_flag(); en.reset_flag();
// When long-pressed the command key, then press and release // When long-pressed the command key, then press and release
@ -775,8 +775,8 @@ fn legacy_keyboard_mode(evt: &KeyEvent) {
if let Some(key) = KEY_MAP.get(&ck.value()) { if let Some(key) = KEY_MAP.get(&ck.value()) {
#[cfg(windows)] #[cfg(windows)]
if let Some(_) = NUMPAD_KEY_MAP.get(&ck.value()) { if let Some(_) = NUMPAD_KEY_MAP.get(&ck.value()) {
disable_numlock = en.get_key_state(Key::NumLock); _disable_numlock = en.get_key_state(Key::NumLock);
if disable_numlock { if _disable_numlock {
en.key_down(Key::NumLock).ok(); en.key_down(Key::NumLock).ok();
en.key_up(Key::NumLock); en.key_up(Key::NumLock);
} }

View File

@ -468,6 +468,7 @@ fn run(sp: GenericService) -> ResultType<()> {
#[cfg(windows)] #[cfg(windows)]
start_uac_elevation_check(); start_uac_elevation_check();
#[cfg(target_os = "linux")]
let mut would_block_count = 0u32; let mut would_block_count = 0u32;
while sp.ok() { while sp.ok() {
@ -570,9 +571,9 @@ fn run(sp: GenericService) -> ResultType<()> {
try_gdi += 1; try_gdi += 1;
} }
would_block_count += 1;
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
{ {
would_block_count += 1;
if !scrap::is_x11() { if !scrap::is_x11() {
if would_block_count >= 100 { if would_block_count >= 100 {
// For now, the user should choose and agree screen sharing agiain. // For now, the user should choose and agree screen sharing agiain.
@ -600,9 +601,12 @@ fn run(sp: GenericService) -> ResultType<()> {
return Err(err.into()); return Err(err.into());
} }
_ => { _ => {
#[cfg(target_os = "linux")]
{
would_block_count = 0; would_block_count = 0;
} }
} }
}
let mut fetched_conn_ids = HashSet::new(); let mut fetched_conn_ids = HashSet::new();
let timeout_millis = 3_000u64; let timeout_millis = 3_000u64;

View File

@ -15,7 +15,7 @@ use hbb_common::{
protobuf::Message as _, protobuf::Message as _,
rendezvous_proto::*, rendezvous_proto::*,
tcp::FramedStream, tcp::FramedStream,
tokio::{self, sync::mpsc, time}, tokio::{self, sync::mpsc},
}; };
use crate::common::get_app_name; use crate::common::get_app_name;

View File

@ -18,8 +18,6 @@ use hbb_common::{
allow_err, fs::TransferJobMeta, log, message_proto::*, rendezvous_proto::ConnType, allow_err, fs::TransferJobMeta, log, message_proto::*, rendezvous_proto::ConnType,
}; };
#[cfg(windows)]
use crate::clipboard_file::*;
use crate::{ use crate::{
client::*, client::*,
ui_interface::has_hwcodec, ui_interface::has_hwcodec,

View File

@ -11,7 +11,7 @@ use std::{
}; };
#[cfg(windows)] #[cfg(windows)]
use clipboard::{cliprdr::CliprdrClientContext, empty_clipboard, ContextSend}; use clipboard::{cliprdr::CliprdrClientContext, empty_clipboard, set_conn_enabled, ContextSend};
use serde_derive::Serialize; use serde_derive::Serialize;
use crate::ipc::{self, new_listener, Connection, Data}; use crate::ipc::{self, new_listener, Connection, Data};
@ -247,10 +247,10 @@ impl<T: InvokeUiCM> IpcTaskRunner<T> {
.await .await
); );
} }
clipboard::set_conn_enabled(conn_id, enabled); set_conn_enabled(conn_id, enabled);
if !enabled { if !enabled {
ContextSend::proc(|context: &mut Box<CliprdrClientContext>| -> u32 { ContextSend::proc(|context: &mut Box<CliprdrClientContext>| -> u32 {
clipboard::empty_clipboard(context, conn_id); empty_clipboard(context, conn_id);
0 0
}); });
} }