Skip to content

Commit

Permalink
Review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
yellowhatter committed Sep 17, 2024
1 parent 4d8ff2b commit 4cf6768
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions commons/zenoh-shm/src/api/cleanup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,20 @@ use crate::cleanup::CLEANUP;

/// Make forced cleanup
/// NOTE: this is a part of a temporary on-exit-cleanup workaround and it will be very likely removed in the future.
/// WARN: The improper usage can break the application logic, impacting SHM-utilizing Sessions in other processes.
/// Cleanup unlinks SHM segments _created_ by current process from filesystem with the following consequences:
/// - Sessions that are not linked to this segment will fail to link it if they try. Such kind of errors are properly handled.
/// - Already linked processes will still have this shared memory mapped and safely accessible
/// - The actual memory will be reclaimed by the OS only after last process using it will close it or exit
///
/// In order to properly cleanup some SHM internals upon process exit, Zenoh installs exit handlers (see atexit() API).
/// The atexit handler is executed only on process exit(), the inconvenience is that terminating signal handlers (like SIGINT)
/// bypass it and terminate the process without cleanup. To eliminate this effect, Zenoh overrides SIGHUP, SIGTERM, SIGINT
/// and SIGQUIT handlers and calls exit() inside to make graceful shutdown. If user is going to override these Zenoh's handlers,
/// the workaround will break, and there are two ways to keep this workaround working:
/// The atexit handler is executed only on process exit(), the inconvenience is that terminating signal handlers
/// (like SIGINT) bypass it and terminate the process without cleanup. To eliminate this effect, Zenoh overrides
/// SIGHUP, SIGTERM, SIGINT and SIGQUIT handlers and calls exit() inside to make graceful shutdown. If user is going to
/// override these Zenoh's handlers, the workaround will break, and there are two ways to keep this workaround working:
/// - execute overridden Zenoh handlers in overriding handler code
/// - call forced_cleanup() anywhere at any time before terminating the process
/// - call force_cleanup_before_exit() anywhere at any time before terminating the process
#[zenoh_macros::unstable_doc]
pub fn forced_cleanup() {
pub fn force_cleanup_before_exit() {
CLEANUP.read().cleanup();
}

0 comments on commit 4cf6768

Please sign in to comment.