mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
fix, reconnect deadlock, introduce connection round control
Signed-off-by: dignow <linlong1265@gmail.com>
This commit is contained in:
@@ -106,7 +106,7 @@ impl<T: InvokeUiSession> Remote<T> {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn io_loop(&mut self, key: &str, token: &str) {
|
||||
pub async fn io_loop(&mut self, key: &str, token: &str, round: u32) {
|
||||
let mut last_recv_time = Instant::now();
|
||||
let mut received = false;
|
||||
let conn_type = if self.handler.is_file_transfer() {
|
||||
@@ -125,6 +125,11 @@ impl<T: InvokeUiSession> Remote<T> {
|
||||
.await
|
||||
{
|
||||
Ok((mut peer, direct, pk)) => {
|
||||
self.handler
|
||||
.connection_round_state
|
||||
.lock()
|
||||
.unwrap()
|
||||
.set_connected();
|
||||
self.handler.set_connection_type(peer.is_secured(), direct); // flutter -> connection_ready
|
||||
self.handler.update_direct(Some(direct));
|
||||
if conn_type == ConnType::DEFAULT_CONN {
|
||||
@@ -245,11 +250,21 @@ impl<T: InvokeUiSession> Remote<T> {
|
||||
self.handler.on_establish_connection_error(err.to_string());
|
||||
}
|
||||
}
|
||||
// set_disconnected_ok is used to check if new connection round is started.
|
||||
let set_disconnected_ok = self
|
||||
.handler
|
||||
.connection_round_state
|
||||
.lock()
|
||||
.unwrap()
|
||||
.set_disconnected(round);
|
||||
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
Client::try_stop_clipboard(&self.handler.session_id);
|
||||
if set_disconnected_ok {
|
||||
Client::try_stop_clipboard(&self.handler.session_id);
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
{
|
||||
if set_disconnected_ok {
|
||||
let conn_id = self.client_conn_id;
|
||||
ContextSend::proc(|context: &mut CliprdrClientContext| -> u32 {
|
||||
empty_clipboard(context, conn_id);
|
||||
|
||||
Reference in New Issue
Block a user