G0.3: watchdog giu 15s khi attach-in-flight (SHM flag) + RAII guard trong attach job (fix kill nham khi GUI mo)

This commit is contained in:
2026-08-15 19:00:32 +07:00
parent 2f7861820e
commit 5313d85926
6 changed files with 41 additions and 3 deletions
+16 -1
View File
@@ -383,6 +383,21 @@ pub fn run() {
false
}
});
// G0.3: an openGUI attach job (reload/attachView on the
// bridge worker) can legitimately outlast the 3s stall
// deadline if it blocks the audio loop's message pump —
// do not kill the bridge for that. Real stalls are still
// caught: attach never takes > 15s; a dead bridge leaves
// the flag stuck and is restarted after the longer wait.
let attach_deadline = guard
.as_ref()
.map(|s| s.attach_in_flight())
.unwrap_or(false);
let stall_deadline = if attach_deadline {
std::time::Duration::from_secs(15)
} else {
std::time::Duration::from_secs(3)
};
if advanced == Some(true) {
last_change = std::time::Instant::now();
down_emitted = false;
@@ -394,7 +409,7 @@ pub fn run() {
"bridge-audio",
AudioFrame { l: l.to_vec(), r: r.to_vec() },
);
} else if last_change.elapsed() >= std::time::Duration::from_secs(3) && !down_emitted {
} else if last_change.elapsed() >= stall_deadline && !down_emitted {
// Check lai truoc khi respawn — Destroyed co the vua set flag.
if SHUTTING_DOWN.load(Ordering::Relaxed) {
break;
+9 -1
View File
@@ -59,6 +59,10 @@ pub struct SharedAudioBufferIPC {
pub midi_queue_count: u32,
pub control_queue: [ControlEventIPC; CONTROL_QUEUE_CAP],
pub control_queue_count: u32,
// G0.3: bridge sets this while an openGUI attach job is in flight.
// Append-only field — offsets of control_queue (2836) and
// control_queue_count (11156) are unchanged.
pub attach_in_flight: u32,
}
pub struct Shm {
@@ -158,6 +162,10 @@ impl Shm {
pub fn block_timestamp(&self) -> u64 {
self.ipc().block_timestamp
}
pub fn attach_in_flight(&self) -> bool {
self.ipc().attach_in_flight != 0
}
}
impl Drop for Shm {
@@ -180,6 +188,6 @@ mod tests {
// native_bridge/tests/shm_selfcheck.cpp asserts the same sizes.
assert_eq!(std::mem::size_of::<MidiEventIPC>(), 12);
assert_eq!(std::mem::size_of::<ControlEventIPC>(), 1040);
assert_eq!(std::mem::size_of::<SharedAudioBufferIPC>(), 11160);
assert_eq!(std::mem::size_of::<SharedAudioBufferIPC>(), 11164);
}
}