mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-04-10 06:11:29 +03:00
fix: sequentially post conn audit (#12152)
* fix: sequentially post conn audit Signed-off-by: fufesou <linlong1266@gmail.com> * Update connection.rs * refact: simplify loop Signed-off-by: fufesou <linlong1266@gmail.com> * Update connection.rs --------- Signed-off-by: fufesou <linlong1266@gmail.com> Co-authored-by: RustDesk <71636191+rustdesk@users.noreply.github.com>
This commit is contained in:
@@ -247,6 +247,9 @@ pub struct Connection {
|
|||||||
multi_ui_session: bool,
|
multi_ui_session: bool,
|
||||||
tx_from_authed: mpsc::UnboundedSender<ipc::Data>,
|
tx_from_authed: mpsc::UnboundedSender<ipc::Data>,
|
||||||
printer_data: Vec<(Instant, String, Vec<u8>)>,
|
printer_data: Vec<(Instant, String, Vec<u8>)>,
|
||||||
|
// For post requests that need to be sent sequentially.
|
||||||
|
// eg. post_conn_audit
|
||||||
|
tx_post_seq: mpsc::UnboundedSender<(String, Value)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ConnInner {
|
impl ConnInner {
|
||||||
@@ -321,6 +324,11 @@ impl Connection {
|
|||||||
let linux_headless_handle =
|
let linux_headless_handle =
|
||||||
LinuxHeadlessHandle::new(_rx_cm_stream_ready, _tx_desktop_ready);
|
LinuxHeadlessHandle::new(_rx_cm_stream_ready, _tx_desktop_ready);
|
||||||
|
|
||||||
|
let (tx_post_seq, rx_post_seq) = mpsc::unbounded_channel();
|
||||||
|
tokio::spawn(async move {
|
||||||
|
Self::post_seq_loop(rx_post_seq).await;
|
||||||
|
});
|
||||||
|
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
let tx_cloned = tx.clone();
|
let tx_cloned = tx.clone();
|
||||||
let mut conn = Self {
|
let mut conn = Self {
|
||||||
@@ -401,6 +409,7 @@ impl Connection {
|
|||||||
retina: Retina::default(),
|
retina: Retina::default(),
|
||||||
tx_from_authed,
|
tx_from_authed,
|
||||||
printer_data: Vec::new(),
|
printer_data: Vec::new(),
|
||||||
|
tx_post_seq,
|
||||||
};
|
};
|
||||||
let addr = hbb_common::try_into_v4(addr);
|
let addr = hbb_common::try_into_v4(addr);
|
||||||
if !conn.on_open(addr).await {
|
if !conn.on_open(addr).await {
|
||||||
@@ -960,7 +969,14 @@ impl Connection {
|
|||||||
}
|
}
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
clear_remapped_keycode();
|
clear_remapped_keycode();
|
||||||
log::info!("Input thread exited");
|
log::debug!("Input thread exited");
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn post_seq_loop(mut rx: mpsc::UnboundedReceiver<(String, Value)>) {
|
||||||
|
while let Some((url, v)) = rx.recv().await {
|
||||||
|
allow_err!(Self::post_audit_async(url, v).await);
|
||||||
|
}
|
||||||
|
log::debug!("post_seq_loop exited");
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn try_port_forward_loop(
|
async fn try_port_forward_loop(
|
||||||
@@ -1117,9 +1133,7 @@ impl Connection {
|
|||||||
v["uuid"] = json!(crate::encode64(hbb_common::get_uuid()));
|
v["uuid"] = json!(crate::encode64(hbb_common::get_uuid()));
|
||||||
v["conn_id"] = json!(self.inner.id);
|
v["conn_id"] = json!(self.inner.id);
|
||||||
v["session_id"] = json!(self.lr.session_id);
|
v["session_id"] = json!(self.lr.session_id);
|
||||||
tokio::spawn(async move {
|
allow_err!(self.tx_post_seq.send((url, v)));
|
||||||
allow_err!(Self::post_audit_async(url, v).await);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_files_for_audit(job_type: fs::JobType, mut files: Vec<FileEntry>) -> Vec<(String, i64)> {
|
fn get_files_for_audit(job_type: fs::JobType, mut files: Vec<FileEntry>) -> Vec<(String, i64)> {
|
||||||
|
|||||||
Reference in New Issue
Block a user