TM store bugfixes
Some checks are pending
EIVE/eive-obsw/pipeline/head Build started...

This commit is contained in:
Robin Müller 2023-03-07 15:34:08 +01:00
parent 6aae94823e
commit 5de7653600
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
3 changed files with 8 additions and 29 deletions

View File

@ -16,6 +16,10 @@ will consitute of a breaking change warranting a new major release:
# [unreleased] # [unreleased]
## Changed
- Persistent TM stores will now create new files on each reboot.
# [v1.35.1] 2023-03-04 # [v1.35.1] 2023-03-04
## Fixed ## Fixed

View File

@ -527,6 +527,10 @@ void scheduling::createPusTasks(TaskFactory& factory, TaskDeadlineMissedFunction
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
scheduling::printAddObjectError("PUS_8", objects::PUS_SERVICE_8_FUNCTION_MGMT); scheduling::printAddObjectError("PUS_8", objects::PUS_SERVICE_8_FUNCTION_MGMT);
} }
result = pusMedPrio->addComponent(objects::PUS_SERVICE_15_TM_STORAGE);
if (result != returnvalue::OK) {
scheduling::printAddObjectError("PUS_15", objects::PUS_SERVICE_15_TM_STORAGE);
}
result = pusMedPrio->addComponent(objects::PUS_SERVICE_11_TC_SCHEDULER); result = pusMedPrio->addComponent(objects::PUS_SERVICE_11_TC_SCHEDULER);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
scheduling::printAddObjectError("PUS_11", objects::PUS_SERVICE_11_TC_SCHEDULER); scheduling::printAddObjectError("PUS_11", objects::PUS_SERVICE_11_TC_SCHEDULER);

View File

@ -28,35 +28,6 @@ PersistentTmStore::PersistentTmStore(object_id_t objectId, const char* baseDir,
} }
ReturnValue_t PersistentTmStore::assignAndOrCreateMostRecentFile() { ReturnValue_t PersistentTmStore::assignAndOrCreateMostRecentFile() {
using namespace std::filesystem;
for (auto const& file : directory_iterator(basePath)) {
if (file.is_directory()) {
continue;
}
auto pathStr = file.path().string();
if (pathStr.find(baseName) == std::string::npos) {
continue;
}
unsigned int underscorePos = pathStr.find_last_of('_');
std::string stampStr = pathStr.substr(underscorePos + 1);
struct tm time {};
if (nullptr == strptime(stampStr.c_str(), FILE_DATE_FORMAT, &time)) {
sif::error << "PersistentTmStore::assignOrCreateMostRecentFile: Error reading timestamp"
<< std::endl;
// Delete the file and re-create it.
activeFile = std::nullopt;
std::filesystem::remove(file.path());
break;
}
time_t fileEpoch = timegm(&time);
// There is still a file within the active time window, so re-use that file for new TMs to
// store.
if (fileEpoch + static_cast<time_t>(rolloverDiffSeconds) > currentTv.tv_sec) {
activeFileTv.tv_sec = fileEpoch;
activeFile = file.path();
break;
}
}
if (not activeFile.has_value()) { if (not activeFile.has_value()) {
return createMostRecentFile(std::nullopt); return createMostRecentFile(std::nullopt);
} }