Skip to content

Commit

Permalink
also check --server in loop
Browse files Browse the repository at this point in the history
  • Loading branch information
rustdesk committed Jun 19, 2024
1 parent 77f1c7e commit 0bf9de8
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions src/platform/macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,27 +514,31 @@ pub fn start_os_service() {
if server.is_none() {
server = get_server_start_time(&mut sys, &path);
}
if let Some((start_time, pid)) = server {
if my_start_time <= start_time + 1 {
log::error!(
let Some((start_time, pid)) = server else {
log::error!(
"Agent not started yet, please restart --server first to make delegate work",
);
std::process::exit(-1);
};
if my_start_time <= start_time + 1 {
log::error!(
"Agent start later, {my_start_time} vs {start_time}, please start --server first to make delegate work",
);
std::process::exit(-1);
}
// only refresh this pid and check if valid, no need to refresh all processes since refreshing all is expensive, about 10ms on my machine
if !sys.refresh_process_specifics(pid, ProcessRefreshKind::new()) {
server = None;
continue;
}
if let Some(p) = sys.process(pid.into()) {
if let Some(p) = get_server_start_time_of(p, &path) {
server = Some((p, pid));
} else {
server = None;
}
std::process::exit(-1);
}
// only refresh this pid and check if valid, no need to refresh all processes since refreshing all is expensive, about 10ms on my machine
if !sys.refresh_process_specifics(pid, ProcessRefreshKind::new()) {
server = None;
continue;
}
if let Some(p) = sys.process(pid.into()) {
if let Some(p) = get_server_start_time_of(p, &path) {
server = Some((p, pid));
} else {
server = None;
}
} else {
server = None;
}
});

Expand Down

0 comments on commit 0bf9de8

Please sign in to comment.