Skip to content

Commit

Permalink
Revert cleanup (#1440)
Browse files Browse the repository at this point in the history
* Revert "SHM cleanup workaround (#1411)"

This reverts commit 9746429.

* hide cleanup API from public
  • Loading branch information
yellowhatter authored Sep 18, 2024
1 parent 91d823d commit 6b97543
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 79 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ stabby = "36.1.1"
sha3 = "0.10.8"
shared_memory = "0.12.4"
shellexpand = "3.1.0"
signal-hook = { version = "0.3.17", default-features = false }
socket2 = { version = "0.5.7", features = ["all"] }
stop-token = "0.7.0"
syn = "2.0"
Expand Down
1 change: 0 additions & 1 deletion commons/zenoh-shm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ num_cpus = { workspace = true, optional = true }
thread-priority = { workspace = true }
lockfree = { workspace = true }
stabby = { workspace = true }
signal-hook = { workspace = true }

[dev-dependencies]
libc = { workspace = true }
35 changes: 0 additions & 35 deletions commons/zenoh-shm/src/api/cleanup.rs

This file was deleted.

1 change: 0 additions & 1 deletion commons/zenoh-shm/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
//

pub mod buffer;
pub mod cleanup;
pub mod client;
pub mod client_storage;
pub mod common;
Expand Down
32 changes: 5 additions & 27 deletions commons/zenoh-shm/src/cleanup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
}
}
}
}
24 changes: 12 additions & 12 deletions commons/zenoh-shm/tests/watchdog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,23 @@ fn watchdog_confirmed_fn() -> impl Fn(usize, usize) -> ZResult<()> + Clone + Sen
}
}

#[ignore]
#[test]
#[ignore]
fn watchdog_confirmed() {
execute_concurrent(1, 10, watchdog_confirmed_fn());
}

#[ignore]
#[test]
#[ignore]
fn watchdog_confirmed_concurrent() {
execute_concurrent(1000, 10, watchdog_confirmed_fn());
}

// TODO: confirmation to dangling watchdog actually writes to potentially-existing
// other watchdog instance from other test running in the same process and changes it's behaviour,
// so we cannot run dangling test in parallel with anything else
#[ignore]
#[test]
#[ignore]
fn watchdog_confirmed_dangling() {
let allocated = GLOBAL_STORAGE
.read()
Expand Down Expand Up @@ -136,14 +136,14 @@ fn watchdog_validated_fn() -> impl Fn(usize, usize) -> ZResult<()> + Clone + Sen
}
}

#[ignore]
#[test]
#[ignore]
fn watchdog_validated() {
execute_concurrent(1, 10, watchdog_validated_fn());
}

#[ignore]
#[test]
#[ignore]
fn watchdog_validated_concurrent() {
execute_concurrent(1000, 10, watchdog_validated_fn());
}
Expand Down Expand Up @@ -176,14 +176,14 @@ fn watchdog_validated_invalid_without_confirmator_fn(
}
}

#[ignore]
#[test]
#[ignore]
fn watchdog_validated_invalid_without_confirmator() {
execute_concurrent(1, 10, watchdog_validated_invalid_without_confirmator_fn());
}

#[ignore]
#[test]
#[ignore]
fn watchdog_validated_invalid_without_confirmator_concurrent() {
execute_concurrent(
1000,
Expand Down Expand Up @@ -241,14 +241,14 @@ fn watchdog_validated_additional_confirmation_fn(
}
}

#[ignore]
#[test]
#[ignore]
fn watchdog_validated_additional_confirmation() {
execute_concurrent(1, 10, watchdog_validated_additional_confirmation_fn());
}

#[ignore]
#[test]
#[ignore]
fn watchdog_validated_additional_confirmation_concurrent() {
execute_concurrent(1000, 10, watchdog_validated_additional_confirmation_fn());
}
Expand Down Expand Up @@ -296,22 +296,22 @@ fn watchdog_validated_overloaded_system_fn(
}
}

#[ignore]
#[test]
#[ignore]
fn watchdog_validated_low_load() {
let _load = CpuLoad::low();
execute_concurrent(1000, 10, watchdog_validated_overloaded_system_fn());
}

#[ignore]
#[test]
#[ignore]
fn watchdog_validated_high_load() {
let _load = CpuLoad::optimal_high();
execute_concurrent(1000, 10, watchdog_validated_overloaded_system_fn());
}

#[ignore]
#[test]
#[ignore]
fn watchdog_validated_overloaded_system() {
let _load = CpuLoad::excessive();
execute_concurrent(1000, 10, watchdog_validated_overloaded_system_fn());
Expand Down
1 change: 0 additions & 1 deletion zenoh/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,6 @@ pub mod shm {
zshm::{zshm, ZShm},
zshmmut::{zshmmut, ZShmMut},
},
cleanup::force_cleanup_before_exit,
client::{shm_client::ShmClient, shm_segment::ShmSegment},
client_storage::{ShmClientStorage, GLOBAL_CLIENT_STORAGE},
common::types::{ChunkID, ProtocolID, SegmentID},
Expand Down

0 comments on commit 6b97543

Please sign in to comment.