Skip to content

Commit 30ee71c

Browse files
泰友imeoer
泰友
authored andcommitted
fix: residual fuse mountpoint after graceful shutdown
1. Case1: Fuse server exits in thread not main. There is possibility that process finishes before shutdown of server. 2. Case2: Fuse server exits in thread of state machine. There is possibiltiy that state machine not responses to signal catch thread. Then dead lock happens. Process exits before shutdown of server. This pr aims to seperator shutdown actions from signal catch handler. It only notifies controller. Controller exits with shutdown of fuse server. No race. No deadlock. Signed-off-by: 泰友 <[email protected]>
1 parent ed2f44d commit 30ee71c

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

service/src/daemon.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,13 +422,16 @@ impl DaemonController {
422422
self.fs_service.lock().unwrap().clone()
423423
}
424424

425-
/// Shutdown all services managed by the controller.
426-
pub fn shutdown(&self) {
425+
/// Notify controller shutdown
426+
pub fn notify_shutdown(&self) {
427427
// Marking exiting state.
428428
self.active.store(false, Ordering::Release);
429429
// Signal the `run_loop()` working thread to exit.
430430
let _ = self.waker.wake();
431+
}
431432

433+
/// Shutdown all services managed by the controller.
434+
pub fn shutdown(&self) {
432435
let daemon = self.daemon.lock().unwrap().take();
433436
if let Some(d) = daemon {
434437
if let Err(e) = d.trigger_stop() {

src/bin/nydusd/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ mod nbd {
720720
}
721721

722722
extern "C" fn sig_exit(_sig: std::os::raw::c_int) {
723-
DAEMON_CONTROLLER.shutdown();
723+
DAEMON_CONTROLLER.notify_shutdown();
724724
}
725725

726726
fn main() -> Result<()> {

0 commit comments

Comments
 (0)