mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
Refact. Replace all tokio::time::interval() (#7173)
* Refact. Replace all `tokio::time::interval()` Signed-off-by: fufesou <shuanglongchen@yeah.net> * Refact Better min_interval for `ThrottledInterval`. Signed-off-by: fufesou <shuanglongchen@yeah.net> --------- Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
@@ -41,7 +41,7 @@ use hbb_common::{
|
||||
tokio::{
|
||||
net::TcpStream,
|
||||
sync::mpsc,
|
||||
time::{self, Duration, Instant, Interval},
|
||||
time::{self, Duration, Instant},
|
||||
},
|
||||
tokio_util::codec::{BytesCodec, Framed},
|
||||
};
|
||||
@@ -175,8 +175,8 @@ pub struct Connection {
|
||||
server: super::ServerPtrWeak,
|
||||
hash: Hash,
|
||||
read_jobs: Vec<fs::TransferJob>,
|
||||
timer: Interval,
|
||||
file_timer: Interval,
|
||||
timer: crate::RustDeskInterval,
|
||||
file_timer: crate::RustDeskInterval,
|
||||
file_transfer: Option<(String, bool)>,
|
||||
port_forward_socket: Option<Framed<TcpStream, BytesCodec>>,
|
||||
port_forward_address: String,
|
||||
@@ -327,8 +327,8 @@ impl Connection {
|
||||
server,
|
||||
hash,
|
||||
read_jobs: Vec::new(),
|
||||
timer: time::interval(SEC30),
|
||||
file_timer: time::interval(SEC30),
|
||||
timer: crate::rustdesk_interval(time::interval(SEC30)),
|
||||
file_timer: crate::rustdesk_interval(time::interval(SEC30)),
|
||||
file_transfer: None,
|
||||
port_forward_socket: None,
|
||||
port_forward_address: "".to_owned(),
|
||||
@@ -419,7 +419,7 @@ impl Connection {
|
||||
if !conn.block_input {
|
||||
conn.send_permission(Permission::BlockInput, false).await;
|
||||
}
|
||||
let mut test_delay_timer = time::interval(TEST_DELAY_TIMEOUT);
|
||||
let mut test_delay_timer = crate::rustdesk_interval(time::interval(TEST_DELAY_TIMEOUT));
|
||||
let mut last_recv_time = Instant::now();
|
||||
|
||||
conn.stream.set_send_timeout(
|
||||
@@ -432,7 +432,7 @@ impl Connection {
|
||||
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
std::thread::spawn(move || Self::handle_input(_rx_input, tx_cloned));
|
||||
let mut second_timer = time::interval(Duration::from_secs(1));
|
||||
let mut second_timer = crate::rustdesk_interval(time::interval(Duration::from_secs(1)));
|
||||
|
||||
loop {
|
||||
tokio::select! {
|
||||
@@ -608,7 +608,7 @@ impl Connection {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
conn.file_timer = time::interval_at(Instant::now() + SEC30, SEC30);
|
||||
conn.file_timer = crate::rustdesk_interval(time::interval_at(Instant::now() + SEC30, SEC30));
|
||||
}
|
||||
}
|
||||
Ok(conns) = hbbs_rx.recv() => {
|
||||
@@ -2054,7 +2054,8 @@ impl Connection {
|
||||
job.is_remote = true;
|
||||
job.conn_id = self.inner.id();
|
||||
self.read_jobs.push(job);
|
||||
self.file_timer = time::interval(MILLI1);
|
||||
self.file_timer =
|
||||
crate::rustdesk_interval(time::interval(MILLI1));
|
||||
self.post_file_audit(
|
||||
FileAuditType::RemoteSend,
|
||||
&s.path,
|
||||
|
||||
@@ -442,7 +442,8 @@ pub mod server {
|
||||
|
||||
match ipc::connect(1000, postfix).await {
|
||||
Ok(mut stream) => {
|
||||
let mut timer = tokio::time::interval(Duration::from_secs(1));
|
||||
let mut timer =
|
||||
crate::rustdesk_interval(tokio::time::interval(Duration::from_secs(1)));
|
||||
let mut nack = 0;
|
||||
loop {
|
||||
tokio::select! {
|
||||
@@ -777,7 +778,7 @@ pub mod client {
|
||||
tokio::spawn(async move {
|
||||
let mut stream = Connection::new(stream);
|
||||
let postfix = postfix.to_owned();
|
||||
let mut timer = tokio::time::interval(Duration::from_secs(1));
|
||||
let mut timer = crate::rustdesk_interval(tokio::time::interval(Duration::from_secs(1)));
|
||||
let mut nack = 0;
|
||||
let mut rx = rx_clone.lock().await;
|
||||
loop {
|
||||
|
||||
Reference in New Issue
Block a user