diff --git a/doc/release-notes/iceoryx2-unreleased.md b/doc/release-notes/iceoryx2-unreleased.md index c37475c61..df3314f5c 100644 --- a/doc/release-notes/iceoryx2-unreleased.md +++ b/doc/release-notes/iceoryx2-unreleased.md @@ -16,6 +16,7 @@ * Fix `open_or_create` race [#108](https://github.com/eclipse-iceoryx/iceoryx2/issues/108) + * Fix `CreationMode::OpenOrCreate` in `iceoryx2-bb-posix::SharedMemory` [#116](https://github.com/eclipse-iceoryx/iceoryx2/issues/116) * Fix undefined behavior in `spsc::{queue|index_queue}` [#87](https://github.com/eclipse-iceoryx/iceoryx2/issues/87) ### Refactoring diff --git a/iceoryx2-bb/posix/src/shared_memory.rs b/iceoryx2-bb/posix/src/shared_memory.rs index 568f7ad05..42cd7650c 100644 --- a/iceoryx2-bb/posix/src/shared_memory.rs +++ b/iceoryx2-bb/posix/src/shared_memory.rs @@ -274,7 +274,13 @@ impl SharedMemoryCreationBuilder { } Err(SharedMemoryCreationError::DoesNotExist) => { shm_created = true; - SharedMemory::shm_create(&self.config.name, &self.config)? + match SharedMemory::shm_create(&self.config.name, &self.config) { + Ok(fd) => fd, + Err(SharedMemoryCreationError::AlreadyExist) => { + SharedMemory::shm_open(&self.config.name, &self.config)? + } + Err(e) => return Err(e), + } } Err(v) => return Err(v), }