mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-03-22 04:31:00 +03:00
--no-server parameter to avoid server ipc occupied by ui (#9272)
Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
@@ -456,16 +456,21 @@ pub async fn start_server(_is_server: bool) {
|
||||
/// * `is_server` - Whether the current client is definitely the server.
|
||||
/// If true, the server will be started.
|
||||
/// Otherwise, client will check if there's already a server and start one if not.
|
||||
/// * `no_server` - If `is_server` is false, whether to start a server if not found.
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
#[tokio::main]
|
||||
pub async fn start_server(is_server: bool) {
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
log::info!("DISPLAY={:?}", std::env::var("DISPLAY"));
|
||||
log::info!("XAUTHORITY={:?}", std::env::var("XAUTHORITY"));
|
||||
}
|
||||
#[cfg(windows)]
|
||||
hbb_common::platform::windows::start_cpu_performance_monitor();
|
||||
pub async fn start_server(is_server: bool, no_server: bool) {
|
||||
use std::sync::Once;
|
||||
static ONCE: Once = Once::new();
|
||||
ONCE.call_once(|| {
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
log::info!("DISPLAY={:?}", std::env::var("DISPLAY"));
|
||||
log::info!("XAUTHORITY={:?}", std::env::var("XAUTHORITY"));
|
||||
}
|
||||
#[cfg(windows)]
|
||||
hbb_common::platform::windows::start_cpu_performance_monitor();
|
||||
});
|
||||
|
||||
if is_server {
|
||||
crate::common::set_server_running(true);
|
||||
@@ -516,8 +521,14 @@ pub async fn start_server(is_server: bool) {
|
||||
crate::ipc::client_get_hwcodec_config_thread(0);
|
||||
}
|
||||
Err(err) => {
|
||||
log::info!("server not started (will try to start): {}", err);
|
||||
std::thread::spawn(|| start_server(true));
|
||||
log::info!("server not started: {err:?}, no_server: {no_server}");
|
||||
if no_server {
|
||||
hbb_common::sleep(1.0).await;
|
||||
std::thread::spawn(|| start_server(false, true));
|
||||
} else {
|
||||
log::info!("try start server");
|
||||
std::thread::spawn(|| start_server(true, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user