install service period protection
how to reproduce: install, click stop service, click start service and click no on uac, it'll show "Service is not running" but can be connected. Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
parent
e98aa81794
commit
d0173fbdc5
@ -1074,7 +1074,7 @@ mod desktop {
|
|||||||
|
|
||||||
pub fn refresh(&mut self) {
|
pub fn refresh(&mut self) {
|
||||||
if !self.sid.is_empty() && is_active_and_seat0(&self.sid) {
|
if !self.sid.is_empty() && is_active_and_seat0(&self.sid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let seat0_values = get_values_of_seat0(&[0, 1, 2]);
|
let seat0_values = get_values_of_seat0(&[0, 1, 2]);
|
||||||
@ -1183,6 +1183,7 @@ pub fn uninstall_service(show_new_window: bool) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn install_service() -> bool {
|
pub fn install_service() -> bool {
|
||||||
|
let _installing = crate::platform::InstallingService::new();
|
||||||
if !has_cmd("systemctl") {
|
if !has_cmd("systemctl") {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -23,9 +23,18 @@ pub mod linux_desktop_manager;
|
|||||||
|
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
use hbb_common::{message_proto::CursorData, ResultType};
|
use hbb_common::{message_proto::CursorData, ResultType};
|
||||||
|
use std::sync::{Arc, Mutex};
|
||||||
#[cfg(not(any(target_os = "macos", target_os = "android", target_os = "ios")))]
|
#[cfg(not(any(target_os = "macos", target_os = "android", target_os = "ios")))]
|
||||||
const SERVICE_INTERVAL: u64 = 300;
|
const SERVICE_INTERVAL: u64 = 300;
|
||||||
|
|
||||||
|
lazy_static::lazy_static! {
|
||||||
|
static ref INSTALLING_SERVICE: Arc<Mutex<bool>>= Default::default();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn installing_service() -> bool {
|
||||||
|
INSTALLING_SERVICE.lock().unwrap().clone()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn is_xfce() -> bool {
|
pub fn is_xfce() -> bool {
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
{
|
{
|
||||||
@ -71,6 +80,21 @@ pub fn get_active_username() -> String {
|
|||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
pub const PA_SAMPLE_RATE: u32 = 48000;
|
pub const PA_SAMPLE_RATE: u32 = 48000;
|
||||||
|
|
||||||
|
pub(crate) struct InstallingService; // please use new
|
||||||
|
|
||||||
|
impl InstallingService {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
*INSTALLING_SERVICE.lock().unwrap() = true;
|
||||||
|
Self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Drop for InstallingService {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
*INSTALLING_SERVICE.lock().unwrap() = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
@ -2167,6 +2167,7 @@ pub fn uninstall_service(show_new_window: bool) -> bool {
|
|||||||
|
|
||||||
pub fn install_service() -> bool {
|
pub fn install_service() -> bool {
|
||||||
log::info!("Installing service...");
|
log::info!("Installing service...");
|
||||||
|
let _installing = crate::platform::InstallingService::new();
|
||||||
let (_, _, _, exe) = get_install_info();
|
let (_, _, _, exe) = get_install_info();
|
||||||
let tmp_path = std::env::temp_dir().to_string_lossy().to_string();
|
let tmp_path = std::env::temp_dir().to_string_lossy().to_string();
|
||||||
let tray_shortcut = get_tray_shortcut(&exe, &tmp_path).unwrap_or_default();
|
let tray_shortcut = get_tray_shortcut(&exe, &tmp_path).unwrap_or_default();
|
||||||
|
@ -79,7 +79,9 @@ impl RendezvousMediator {
|
|||||||
crate::platform::linux_desktop_manager::start_xdesktop();
|
crate::platform::linux_desktop_manager::start_xdesktop();
|
||||||
loop {
|
loop {
|
||||||
Config::reset_online();
|
Config::reset_online();
|
||||||
if Config::get_option("stop-service").is_empty() {
|
if Config::get_option("stop-service").is_empty()
|
||||||
|
&& !crate::platform::installing_service()
|
||||||
|
{
|
||||||
if !nat_tested {
|
if !nat_tested {
|
||||||
crate::test_nat_type();
|
crate::test_nat_type();
|
||||||
nat_tested = true;
|
nat_tested = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user