tokio1, windows not test yet

This commit is contained in:
rustdesk
2021-06-25 19:42:51 +08:00
parent 25a83f6b4a
commit dc3fcda2c9
23 changed files with 169 additions and 154 deletions

View File

@@ -78,7 +78,7 @@ impl Interface for Session {
}
}
#[tokio::main(basic_scheduler)]
#[tokio::main(flavor = "current_thread")]
pub async fn start_one_port_forward(id: String, port: i32, remote_host: String, remote_port: i32) {
crate::common::test_rendezvous_server();
crate::common::test_nat_type();

View File

@@ -156,7 +156,7 @@ pub fn test_nat_type() {
});
}
#[tokio::main(basic_scheduler)]
#[tokio::main(flavor = "current_thread")]
async fn test_nat_type_() -> ResultType<bool> {
log::info!("Testing nat ...");
let start = std::time::Instant::now();
@@ -237,7 +237,7 @@ pub async fn get_nat_type(ms_timeout: u64) -> i32 {
}
#[cfg(any(target_os = "android", target_os = "ios", feature = "cli"))]
#[tokio::main(basic_scheduler)]
#[tokio::main(flavor = "current_thread")]
async fn test_rendezvous_server_() {
let servers = Config::get_rendezvous_servers();
hbb_common::config::ONLINE.lock().unwrap().clear();
@@ -345,7 +345,7 @@ pub fn check_software_update() {
std::thread::spawn(move || allow_err!(_check_software_update()));
}
#[tokio::main(basic_scheduler)]
#[tokio::main(flavor = "current_thread")]
async fn _check_software_update() -> hbb_common::ResultType<()> {
sleep(3.).await;
let rendezvous_server = get_rendezvous_server(1_000).await;

View File

@@ -91,7 +91,7 @@ pub enum Data {
Test,
}
#[tokio::main(basic_scheduler)]
#[tokio::main(flavor = "current_thread")]
pub async fn start(postfix: &str) -> ResultType<()> {
let mut incoming = new_listener(postfix).await?;
loop {
@@ -336,7 +336,7 @@ impl Connection {
}
}
#[tokio::main(basic_scheduler)]
#[tokio::main(flavor = "current_thread")]
async fn get_config(name: &str) -> ResultType<Option<String>> {
get_config_async(name, 1_000).await
}
@@ -352,7 +352,7 @@ async fn get_config_async(name: &str, ms_timeout: u64) -> ResultType<Option<Stri
return Ok(None);
}
#[tokio::main(basic_scheduler)]
#[tokio::main(flavor = "current_thread")]
async fn set_config(name: &str, value: String) -> ResultType<()> {
let mut c = connect(1000, "").await?;
c.send_config(name, value).await?;
@@ -409,7 +409,7 @@ async fn get_options_(ms_timeout: u64) -> ResultType<HashMap<String, String>> {
}
}
#[tokio::main(basic_scheduler)]
#[tokio::main(flavor = "current_thread")]
pub async fn get_options() -> HashMap<String, String> {
get_options_(1000).await.unwrap_or(Config::get_options())
}
@@ -432,7 +432,7 @@ pub fn set_option(key: &str, value: &str) {
set_options(options).ok();
}
#[tokio::main(basic_scheduler)]
#[tokio::main(flavor = "current_thread")]
pub async fn set_options(value: HashMap<String, String>) -> ResultType<()> {
Config::set_options(value.clone());
connect(1000, "")

View File

@@ -386,7 +386,7 @@ extern "C" {
fn BlockInput(v: BOOL) -> BOOL;
}
#[tokio::main(basic_scheduler)]
#[tokio::main(flavor = "current_thread")]
async fn run_service(_arguments: Vec<OsString>) -> ResultType<()> {
let event_handler = move |control_event| -> ServiceControlHandlerResult {
log::info!("Got service control event: {:?}", control_event);
@@ -546,7 +546,7 @@ pub fn run_as_user(arg: &str) -> ResultType<Option<std::process::Child>> {
Ok(None)
}
#[tokio::main(basic_scheduler)]
#[tokio::main(flavor = "current_thread")]
async fn send_close(postfix: &str) -> ResultType<()> {
send_close_async(postfix).await
}

View File

@@ -2,12 +2,12 @@ use crate::client::*;
use hbb_common::{
allow_err, bail,
config::CONNECT_TIMEOUT,
futures::SinkExt,
futures::{SinkExt, StreamExt},
log,
message_proto::*,
protobuf::Message as _,
tcp, timeout,
tokio::{self, net::TcpStream, stream::StreamExt, sync::mpsc},
tokio::{self, net::TcpStream, sync::mpsc},
tokio_util::codec::{BytesCodec, Framed},
ResultType, Stream,
};

View File

@@ -34,7 +34,7 @@ pub fn new() -> GenericService {
#[cfg(target_os = "linux")]
mod pa_impl {
use super::*;
#[tokio::main(basic_scheduler)]
#[tokio::main(flavor = "current_thread")]
pub async fn run(sp: GenericService) -> ResultType<()> {
if let Ok(mut stream) = crate::ipc::connect(1000, "_pa").await {
let mut encoder =

View File

@@ -5,11 +5,10 @@ use crate::ipc;
use hbb_common::{
config::Config,
fs,
futures::SinkExt,
futures::{SinkExt, StreamExt},
sleep, timeout,
tokio::{
net::TcpStream,
stream::StreamExt,
sync::mpsc,
time::{self, Duration, Instant, Interval},
},

View File

@@ -518,7 +518,7 @@ fn handle_key_(evt: &KeyEvent) {
}
}
#[tokio::main(basic_scheduler)]
#[tokio::main(flavor = "current_thread")]
async fn send_sas() -> ResultType<()> {
let mut stream = crate::ipc::connect(1000, crate::POSTFIX_SERVICE).await?;
timeout(1000, stream.send(&crate::ipc::Data::SAS)).await??;

View File

@@ -595,7 +595,7 @@ pub fn check_zombie(childs: Childs) {
// notice: avoiding create ipc connecton repeatly,
// because windows named pipe has serious memory leak issue.
#[tokio::main(basic_scheduler)]
#[tokio::main(flavor = "current_thread")]
async fn check_connect_status_(
reconnect: bool,
status: Arc<Mutex<(i32, bool)>>,

View File

@@ -330,7 +330,7 @@ impl sciter::EventHandler for ConnectionManager {
}
}
#[tokio::main(basic_scheduler)]
#[tokio::main(flavor = "current_thread")]
async fn start_ipc(cm: ConnectionManager) {
match new_listener("_cm").await {
Ok(mut incoming) => {
@@ -387,7 +387,7 @@ async fn start_ipc(cm: ConnectionManager) {
}
#[cfg(target_os = "linux")]
#[tokio::main(basic_scheduler)]
#[tokio::main(flavor = "current_thread")]
async fn start_pa() {
use hbb_common::config::APP_NAME;
use libpulse_binding as pulse;

View File

@@ -1019,7 +1019,7 @@ async fn start_one_port_forward(
log::info!("port forward (:{}) exit", port);
}
#[tokio::main(basic_scheduler)]
#[tokio::main(flavor = "current_thread")]
async fn io_loop(handler: Handler) {
let (sender, mut receiver) = mpsc::unbounded_channel::<Data>();
handler.write().unwrap().sender = Some(sender.clone());