Refactoring of SharedMemory.h (#418)

Function names match Detector.h
Removed double print due to LOG then throw
file descriptor not kept as a member variable
This commit is contained in:
Erik Fröjdh
2022-03-28 16:13:56 +02:00
committed by GitHub
parent 66900da476
commit e55e18d5e9
6 changed files with 149 additions and 227 deletions

View File

@@ -26,8 +26,8 @@ void freeSharedMemory(int detectorIndex, int moduleIndex) {
// single module
if (moduleIndex >= 0) {
SharedMemory<sharedModule> moduleShm(detectorIndex, moduleIndex);
if (moduleShm.IsExisting()) {
moduleShm.RemoveSharedMemory();
if (moduleShm.exists()) {
moduleShm.removeSharedMemory();
}
return;
}
@@ -36,21 +36,21 @@ void freeSharedMemory(int detectorIndex, int moduleIndex) {
SharedMemory<sharedDetector> detectorShm(detectorIndex, -1);
int numDetectors = 0;
if (detectorShm.IsExisting()) {
detectorShm.OpenSharedMemory();
if (detectorShm.exists()) {
detectorShm.openSharedMemory();
numDetectors = detectorShm()->numberOfModules;
detectorShm.RemoveSharedMemory();
detectorShm.removeSharedMemory();
}
for (int i = 0; i < numDetectors; ++i) {
SharedMemory<sharedModule> moduleShm(detectorIndex, i);
moduleShm.RemoveSharedMemory();
moduleShm.removeSharedMemory();
}
// Ctb configuration
SharedMemory<CtbConfig> ctbShm(detectorIndex, -1, CtbConfig::shm_tag());
if (ctbShm.IsExisting())
ctbShm.RemoveSharedMemory();
if (ctbShm.exists())
ctbShm.removeSharedMemory();
}
using defs = slsDetectorDefs;