mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-08-24 07:06:32 +00:00
fix(linux): make quit_cm actually quit the connection manager (#15718)
quit_gui() ends the process on Windows (std::process::exit) and macOS (NSApp terminate), but on Linux it calls gtk_main_quit(), which has no effect in the Flutter connection manager: flutter/linux/main.cc runs g_application_run() (GtkApplication), so gtk_main() is never called and the assertion inside gtk_main_quit() just fails. quit_cm() is the only caller that relies on quit_gui() to end the process. The main window path in ipc.rs calls std::process::exit(-1) right after it, and the two remaining call sites are in the Sciter UI, which is not compiled for flutter builds. So a connection manager reaching quit_cm() on Linux kept running while no longer serving the `_cm` ipc endpoint, which also stops the server from reusing it, so the next connection spawns one more. NOTE: this is a fallback, not an explanation for the stale processes of #15698: a client merely disconnecting does not reach quit_cm(), the Flutter side closes the window instead. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
9aeb54cf33
commit
e63df74715
@@ -1686,6 +1686,19 @@ pub fn quit_cm() {
|
||||
// in case of std::process::exit not work
|
||||
log::info!("quit cm");
|
||||
CLIENTS.write().unwrap().clear();
|
||||
// `quit_gui()` ends the process on Windows and macOS, but on Linux it calls
|
||||
// `gtk_main_quit()`, which has no effect in the Flutter connection manager:
|
||||
// `flutter/linux/main.cc` runs `g_application_run()` (GtkApplication), so
|
||||
// `gtk_main()` is never called. Exit directly instead, otherwise this
|
||||
// process keeps running while no longer serving the `_cm` ipc endpoint, so
|
||||
// the server can't reuse it and spawns one more connection manager.
|
||||
//
|
||||
// NOTE: a client merely disconnecting does not come here, the Flutter side
|
||||
// closes the window then, so this is a fallback rather than an explanation
|
||||
// for the stale processes of #15698.
|
||||
#[cfg(all(target_os = "linux", feature = "flutter"))]
|
||||
std::process::exit(0);
|
||||
#[cfg(not(all(target_os = "linux", feature = "flutter")))]
|
||||
crate::platform::quit_gui();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user