-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Revert "SHM cleanup workaround (#1411)" This reverts commit 9746429. * hide cleanup API from public
- Loading branch information
1 parent
91d823d
commit 6b97543
Showing
8 changed files
with
17 additions
and
79 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,6 @@ | |
// | ||
|
||
pub mod buffer; | ||
pub mod cleanup; | ||
pub mod client; | ||
pub mod client_storage; | ||
pub mod common; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,6 @@ | |
// ZettaScale Zenoh Team, <[email protected]> | ||
// | ||
|
||
use signal_hook::consts::signal::*; | ||
use static_init::dynamic; | ||
|
||
/// A global cleanup, that is guaranteed to be dropped at normal program exit and that will | ||
|
@@ -27,43 +26,22 @@ pub(crate) struct Cleanup { | |
|
||
impl Cleanup { | ||
fn new() -> Self { | ||
// todo: this is a workaround to make sure Cleanup will be executed even if process terminates via signal handlers | ||
// that execute std::terminate instead of exit | ||
for signal in [ | ||
#[cfg(not(target_os = "windows"))] | ||
SIGHUP, | ||
SIGTERM, | ||
SIGINT, | ||
#[cfg(not(target_os = "windows"))] | ||
SIGQUIT, | ||
] { | ||
unsafe { | ||
let _ = signal_hook::low_level::register(signal, || { | ||
std::process::exit(0); | ||
}); | ||
} | ||
} | ||
|
||
Self { | ||
cleanups: Default::default(), | ||
} | ||
} | ||
|
||
pub(crate) fn cleanup(&self) { | ||
while let Some(cleanup) = self.cleanups.pop() { | ||
if let Some(f) = cleanup { | ||
f(); | ||
} | ||
} | ||
} | ||
|
||
pub(crate) fn register_cleanup(&self, cleanup_fn: Box<dyn FnOnce() + Send>) { | ||
self.cleanups.push(Some(cleanup_fn)); | ||
} | ||
} | ||
|
||
impl Drop for Cleanup { | ||
fn drop(&mut self) { | ||
self.cleanup(); | ||
while let Some(cleanup) = self.cleanups.pop() { | ||
if let Some(f) = cleanup { | ||
f(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters