Skip to content

Commit

Permalink
[eclipse-iceoryx#51] Only remove shm state file when unlink was succe…
Browse files Browse the repository at this point in the history
…ssful or the shared memory does not exist
  • Loading branch information
elfenpiff committed Dec 22, 2023
1 parent edf0eef commit af0ec81
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions iceoryx2-pal/posix/src/macos/mman.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,13 @@ pub unsafe fn shm_open(name: *const char, oflag: int, mode: mode_t) -> int {

pub unsafe fn shm_unlink(name: *const char) -> int {
let real_name = get_real_shm_name(name);
remove(shm_file_path(name, SHM_STATE_SUFFIX).as_ptr().cast());

if let Some(real_name) = real_name {
return crate::internal::shm_unlink(real_name.as_ptr().cast());
let ret_val = crate::internal::shm_unlink(real_name.as_ptr().cast());
if ret_val == 0 || (ret_val == -1 && Errno::get() == Errno::ENOENT) {
remove(shm_file_path(name, SHM_STATE_SUFFIX).as_ptr().cast());
}
return ret_val;
}

Errno::set(Errno::ENOENT);
Expand Down

0 comments on commit af0ec81

Please sign in to comment.