Skip to content

Commit 4d5c543

Browse files
committed
fix(desktop): drop supervisor lock before pause confirmation dialog
- Sample is_running state under a short lock, then release before calling confirm_panel_pause() to avoid deadlocking the UI thread on Linux - gtk::Dialog::run() nests the GTK loop which can dispatch RefreshStatus events that also need the supervisor mutex; holding the lock across the dialog caused a 2-second status poll to freeze the pause confirmation - Re-acquire the lock before stopping to handle the case where the supervisor state changed while the dialog was open - Restructure the pause/resume logic to cleanly separate lock-acquisition phases
1 parent 6b883f9 commit 4d5c543

5 files changed

Lines changed: 26 additions & 8 deletions

File tree

.textile-monorepo-source

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
a953771c46c910ce1507c781200778ef395adb98
1+
8bb0b2114ccfeb59c263c8beb77ffa4b0d19912e

.textile-stitch-release-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.164
1+
0.1.165

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "stitch-bot"
3-
version = "0.1.164"
3+
version = "0.1.165"
44
edition = "2021"
55
description = "Stitch — Textile filler-network operator bot; market-makes the filler order book with signed UniswapX limit orders."
66
license = "AGPL-3.0-or-later"

src/bin/stitch-desktop/main.rs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -669,15 +669,33 @@ fn run() -> Result<()> {
669669
}
670670

671671
fn toggle_panel(supervisor: &Arc<Mutex<PanelSupervisor>>) {
672-
if let Ok(mut s) = supervisor.lock() {
673-
if s.is_running() {
674-
if !confirm_panel_pause() {
672+
// Sample running state under a short lock, then drop it before any
673+
// blocking confirmation. On Linux, gtk::Dialog::run() nests the GTK loop
674+
// and can dispatch RefreshStatus, which also needs this mutex — holding
675+
// it across the dialog deadlocks the UI thread.
676+
let running = match supervisor.lock() {
677+
Ok(mut s) => s.is_running(),
678+
Err(_) => return,
679+
};
680+
681+
if running {
682+
if !confirm_panel_pause() {
683+
return;
684+
}
685+
if let Ok(mut s) = supervisor.lock() {
686+
// State may have changed while the dialog was open.
687+
if !s.is_running() {
675688
return;
676689
}
677690
if let Err(e) = s.stop() {
678691
eprintln!("pause failed: {e:#}");
679692
}
680-
} else if let Err(e) = s.start() {
693+
}
694+
return;
695+
}
696+
697+
if let Ok(mut s) = supervisor.lock() {
698+
if let Err(e) = s.start() {
681699
eprintln!("resume failed: {e:#}");
682700
}
683701
}

0 commit comments

Comments
 (0)