Mutex-protect the time conversion in the URLSynchronization to prevent a rare crash when accessing SpiceManager multithreaded

This commit is contained in:
Alexander Bock
2024-04-05 11:18:32 +02:00
parent 68983e1c6b
commit 76b99a2e01
2 changed files with 6 additions and 1 deletions

View File

@@ -222,8 +222,11 @@ bool UrlSynchronization::isEachFileValid() {
// Valid to: yyyy-mm-ddThr:mn:sc.xxx
if (ossyncVersion == "1.0") {
// We need to mutex-protect the access to the time conversion for now
std::lock_guard guard(_mutex);
ghoul::getline(file >> std::ws, line);
std::string& fileIsValidToDate = line;
const std::string& fileIsValidToDate = line;
const double fileValidAsJ2000 = Time::convertTime(fileIsValidToDate);
const std::string todaysDate = Time::currentWallTime();

View File

@@ -122,6 +122,8 @@ private:
/// Determines how long the file is valid before it should be downloaded again
double _secondsUntilResync = MaxDateAsJ2000;
std::mutex _mutex;
};
} // namespace openspace