mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-04-08 15:31:27 +03:00
Fix/linux keep terminal sessions (#12222)
* fix: linux, keep terminal sessions Signed-off-by: fufesou <linlong1266@gmail.com> * fix: terminal service stucked at reader join Signed-off-by: fufesou <linlong1266@gmail.com> --------- Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
19
src/ipc.rs
19
src/ipc.rs
@@ -282,6 +282,8 @@ pub enum Data {
|
||||
not(any(target_os = "android", target_os = "ios"))
|
||||
))]
|
||||
ControllingSessionCount(usize),
|
||||
#[cfg(target_os = "linux")]
|
||||
TerminalSessionCount(usize),
|
||||
#[cfg(target_os = "windows")]
|
||||
PortForwardSessionCount(Option<usize>),
|
||||
SocksWs(Option<Box<(Option<config::Socks5Server>, String)>>),
|
||||
@@ -642,6 +644,11 @@ async fn handle(data: Data, stream: &mut Connection) {
|
||||
Data::ControllingSessionCount(count) => {
|
||||
crate::updater::update_controlling_session_count(count);
|
||||
}
|
||||
#[cfg(target_os = "linux")]
|
||||
Data::TerminalSessionCount(_) => {
|
||||
let count = crate::terminal_service::get_terminal_session_count(true);
|
||||
allow_err!(stream.send(&Data::TerminalSessionCount(count)).await);
|
||||
}
|
||||
#[cfg(feature = "hwcodec")]
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
Data::CheckHwcodec => {
|
||||
@@ -1388,6 +1395,18 @@ pub async fn update_controlling_session_count(count: usize) -> ResultType<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[tokio::main(flavor = "current_thread")]
|
||||
pub async fn get_terminal_session_count() -> ResultType<usize> {
|
||||
let ms_timeout = 1_000;
|
||||
let mut c = connect(ms_timeout, "").await?;
|
||||
c.send(&Data::TerminalSessionCount(0)).await?;
|
||||
if let Some(Data::TerminalSessionCount(c)) = c.next_timeout(ms_timeout).await? {
|
||||
return Ok(c);
|
||||
}
|
||||
Ok(0)
|
||||
}
|
||||
|
||||
async fn handle_wayland_screencast_restore_token(
|
||||
key: String,
|
||||
value: String,
|
||||
|
||||
Reference in New Issue
Block a user