diff --git a/ipc/hypervisor/src/service.rs.in b/ipc/hypervisor/src/service.rs.in index 69585ee6c..938cea345 100644 --- a/ipc/hypervisor/src/service.rs.in +++ b/ipc/hypervisor/src/service.rs.in @@ -42,7 +42,7 @@ pub struct ModuleState { #[derive(Ipc)] pub trait ControlService { - fn shutdown(&self); + fn shutdown(&self) -> bool; } #[derive(Ipc)] diff --git a/parity/boot.rs b/parity/boot.rs index 1614317b8..aa0e4b82b 100644 --- a/parity/boot.rs +++ b/parity/boot.rs @@ -42,7 +42,7 @@ pub fn host_service(addr: &str, stop_guard: A let mut worker = nanoipc::Worker::::new(&service); worker.add_reqrep(&socket_url).unwrap(); - while !stop_guard.load(Ordering::Relaxed) { + while !stop_guard.load(Ordering::SeqCst) { worker.poll(); } }); diff --git a/parity/sync.rs b/parity/sync.rs index 95c9924c6..27e9d5a6a 100644 --- a/parity/sync.rs +++ b/parity/sync.rs @@ -31,9 +31,10 @@ struct SyncControlService { } impl ControlService for SyncControlService { - fn shutdown(&self) { + fn shutdown(&self) -> bool { trace!(target: "hypervisor", "Received shutdown from control service"); - self.stop.store(true, ::std::sync::atomic::Ordering::Relaxed); + self.stop.store(true, ::std::sync::atomic::Ordering::SeqCst); + true } } @@ -75,14 +76,15 @@ pub fn main() { let control_service = Arc::new(SyncControlService::default()); let as_control = control_service.clone() as Arc; let mut worker = nanoipc::Worker::::new(&as_control); + let thread_stop = control_service.stop.clone(); worker.add_reqrep( &service_urls::with_base(&service_config.io_path, service_urls::SYNC_CONTROL) ).unwrap(); - while !control_service.stop.load(::std::sync::atomic::Ordering::Relaxed) { + while !thread_stop.load(::std::sync::atomic::Ordering::SeqCst) { worker.poll(); } - service_stop.store(true, ::std::sync::atomic::Ordering::Relaxed); + service_stop.store(true, ::std::sync::atomic::Ordering::SeqCst); hypervisor.module_shutdown(SYNC_MODULE_ID); trace!(target: "hypervisor", "Sync process terminated gracefully");