Dev/verify shm (#1276)
Some checks failed
Build on RHEL9 / build (push) Failing after 3m41s
Build on RHEL8 / build (push) Failing after 5m10s

* removed verify, update, fixed getUser to be a free function, generated commands, python bindings yet to do

* python bindings

* fixed tests

* minor

* minor

* format
This commit is contained in:
2025-08-23 10:23:27 +02:00
committed by GitHub
parent 15cbaa509e
commit fff5fa73be
18 changed files with 198 additions and 209 deletions

View File

@@ -61,6 +61,54 @@ void freeSharedMemory(const int detectorIndex, const int moduleIndex) {
}
}
std::string getUserDetails(const int detectorIndex) {
int numModules = 0;
defs::detectorType type = defs::GENERIC;
pid_t pid = -1;
std::string hostname = "Unknown";
std::string user = "Unknown";
std::string date = "Unknown";
SharedMemory<sharedDetector> detectorShm(detectorIndex, -1);
if (detectorShm.exists()) {
detectorShm.openSharedMemory(false);
if (detectorShm()->shmversion < DETECTOR_SHMAPIVERSION) {
detectorShm.unmapSharedMemory();
throw SharedMemoryError(
"Detector Shared memory version too old to get user details!");
}
numModules = detectorShm()->totalNumberOfModules;
type = detectorShm()->detType;
pid = detectorShm()->lastPID;
user = detectorShm()->lastUser;
date = detectorShm()->lastDate;
detectorShm.unmapSharedMemory();
}
for (int imod = 0; imod != numModules; ++imod) {
SharedMemory<sharedModule> moduleShm(detectorIndex, imod);
moduleShm.openSharedMemory(false);
if (moduleShm()->shmversion < MODULE_SHMAPIVERSION) {
LOG(logWARNING) << "Module Shared Memory too old to get hostname";
} else {
hostname = moduleShm()->hostname;
}
moduleShm.unmapSharedMemory();
}
std::ostringstream userDetails;
userDetails << "Detector Index: " << detectorIndex << "\n"
<< "Number of Modules: " << numModules << "\n"
<< "Type: " << type << "\n"
<< "PID: " << pid << "\n"
<< "User: " << user << "\n"
<< "Date: " << date << "\n"
<< "Hostname: " << hostname << "\n";
return userDetails.str();
}
using defs = slsDetectorDefs;
Detector::Detector(int shm_id) : pimpl(make_unique<DetectorImpl>(shm_id)) {}
@@ -2828,8 +2876,6 @@ Result<ns> Detector::getMeasurementTime(Positions pos) const {
return pimpl->Parallel(&Module::getMeasurementTime, pos);
}
std::string Detector::getUserDetails() const { return pimpl->getUserDetails(); }
std::vector<uint16_t> Detector::getValidPortNumbers(uint16_t start_port) {
int num_sockets_per_detector = getNumberofUDPInterfaces({}).tsquash(
"Number of UDP Interfaces is not consistent among modules");