Dev/shm fix remove (#1279)
Some checks failed
Build on RHEL9 / build (push) Failing after 3m30s
Build on RHEL8 / build (push) Failing after 5m9s

* one doesnt need to open shared memory to call removesharedmemory, and calling hasMemoryvalid without opening will cause segfault (not used now, but could in the future)

* fix test on shm
This commit is contained in:
2025-08-25 16:20:19 +02:00
committed by GitHub
parent 9af571ea0e
commit 5b069d85a8
5 changed files with 36 additions and 20 deletions

View File

@@ -30,16 +30,15 @@ This document describes the differences between vx.x.x and vx.0.2
2 On-board Detector Server Compatibility
==========================================
Eiger 9.0.0
Jungfrau 9.0.0
Mythen3 9.0.0
Gotthard2 9.0.0
Moench 9.0.0
Eiger 10.0.0
Jungfrau 10.0.0
Mythen3 10.0.0
Gotthard2 10.0.0
Moench 10.0.0
On-board Detector Server Upgrade
@@ -62,17 +61,16 @@ This document describes the differences between vx.x.x and vx.0.2
3 Firmware Requirements
========================
Eiger 02.10.2023 (v32) (updated in 7.0.3)
Jungfrau 20.09.2023 (v1.5, HW v1.0) (updated in 8.0.0)
21.09.2023 (v2.5, HW v2.0) (updated in 8.0.0)
Jungfrau 09.02.2025 (v1.6, HW v1.0) (updated in 9.1.0)
08.02.2025 (v2.6, HW v2.0) (updated in 9.1.0)
Mythen3 11.10.2024 (v1.5) (updated in 9.0.0)
Mythen3 13.11.2024 (v2.0) (updated in 9.0.0)
Gotthard2 03.10.2024 (v1.0) (updated in 9.0.0)
Moench 26.10.2023 (v2.0) (updated in 9.0.0)
Moench 26.10.2023 (v2.0) (updated in 8.0.2)
Detector Upgrade
@@ -187,6 +185,14 @@ This document describes the differences between vx.x.x and vx.0.2
https://slsdetectorgroup.github.io/devdoc/udpheader.html
https://slsdetectorgroup.github.io/devdoc/udpdetspec.html
Output Data:
https://slsdetectorgroup.github.io/devdoc/dataformat.html
https://slsdetectorgroup.github.io/devdoc/fileformat.html
https://slsdetectorgroup.github.io/devdoc/slsreceiverheaderformat.html
https://slsdetectorgroup.github.io/devdoc/masterfileattributes.html
https://slsdetectorgroup.github.io/devdoc/binaryfileformat.html
https://slsdetectorgroup.github.io/devdoc/hdf5fileformat.html
slsReceiver Zmq Format:
https://slsdetectorgroup.github.io/devdoc/slsreceiver.html#zmq-json-header-format
@@ -206,3 +212,4 @@ This document describes the differences between vx.x.x and vx.0.2
dhanya.thattil@psi.ch
erik.frojdh@psi.ch
alice.mazzoleni@psi.ch

View File

@@ -29,7 +29,6 @@ void freeSharedMemory(const int detectorIndex, const int moduleIndex) {
if (moduleIndex >= 0) {
SharedMemory<sharedModule> moduleShm(detectorIndex, moduleIndex);
if (moduleShm.exists()) {
moduleShm.openSharedMemory(false);
moduleShm.removeSharedMemory();
}
return;
@@ -48,7 +47,6 @@ void freeSharedMemory(const int detectorIndex, const int moduleIndex) {
for (int i = 0; i < numDetectors; ++i) {
SharedMemory<sharedModule> moduleShm(detectorIndex, i);
if (moduleShm.exists()) {
moduleShm.openSharedMemory(false);
moduleShm.removeSharedMemory();
}
}
@@ -56,7 +54,6 @@ void freeSharedMemory(const int detectorIndex, const int moduleIndex) {
// Ctb configuration
SharedMemory<CtbConfig> ctbShm(detectorIndex, -1, CtbConfig::shm_tag());
if (ctbShm.exists()) {
ctbShm.openSharedMemory(false);
ctbShm.removeSharedMemory();
}
}

View File

@@ -3396,11 +3396,11 @@ void Module::createSharedMemory(detectorType type, int det_id) {
// ensure shared memory was not created before
if (shm.exists()) {
throw SharedMemoryError(
"This shared memory " + shm.getName() +
" should have been deleted before! Free it to continue.");
LOG(logWARNING)
<< "This shared memory " + shm.getName() +
" should have been deleted before! Freeing it to continue.";
shm.removeSharedMemory();
}
shm.createSharedMemory();
initializeModuleStructure(type);
}

View File

@@ -57,6 +57,8 @@ template <typename T> class SharedMemory {
name = constructSharedMemoryName(detectorId, moduleIndex, tag);
}
explicit SharedMemory(const std::string &shm_name) : name(shm_name) {}
// Disable copy, since we refer to a unique location
SharedMemory(const SharedMemory &) = delete;
SharedMemory &operator=(const SharedMemory &other) = delete;
@@ -81,8 +83,12 @@ template <typename T> class SharedMemory {
}
bool memoryHasValidFlag() const {
if (shared_struct == nullptr) {
throw SharedMemoryError(
"Shared memory not mapped. Cannot check validity.");
}
// CtbConfig did not have shmversion before, so exact value check
if constexpr (is_type<CtbConfig, T>()) {
// CtbConfig did not have shmversion before, so exact value check
if (shared_struct->shmversion == SHM_IS_VALID_CHECK_VERSION) {
return true;
}
@@ -99,11 +105,18 @@ template <typename T> class SharedMemory {
}
void invalidate() {
bool wasValid = true;
if (shared_struct == nullptr) {
wasValid = false;
openSharedMemory(false);
}
// also called by obsolete shm test structure (so check added)
if constexpr (has_bool_isValid<T>::value) {
if (memoryHasValidFlag())
shared_struct->isValid = false;
}
if (!wasValid)
unmapSharedMemory();
}
T *operator()() {

View File

@@ -33,7 +33,6 @@ struct ObsoleteCtbData {
void freeShm(const int dindex, const int mIndex) {
SharedMemory<Data> shm(dindex, mIndex);
if (shm.exists()) {
shm.openSharedMemory(false);
shm.removeSharedMemory();
}
}