18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-19 22:44:59 +01:00

fix(physicslog): failed logs kept within 64 MB in all, cut outside the lock, never written twice; the writer knows itself when stopped

The lines kept while files can't be written are cut to their share of 64 MB
before the lock the simulation waits on. A log written in part is cut back to
its length, so the next try doesn't write its start twice. A stop from the
writer itself is told by its id even after another thread took it to join, and
the watchdog's flush waits at most its time, the writing on a thread of its own.
This commit is contained in:
maj00r
2026-11-15 23:38:24 +01:00
parent 5d0bf6ed00
commit 043b9fb2f0
5 changed files with 55 additions and 26 deletions

View File

@@ -262,8 +262,8 @@ void test_manager::check_wall_clock(double const Elapsed)
// but which doesn't close ends with its result
if (false == conclude(test_result::timeout, std::format("still running after {:.0f} s of real time (test.wall_timeout)", limit)))
ErrorLog(std::format("test: the simulator was still running {:.0f} s of real time after the start, ended", limit));
// what was logged last gets written, unless the log is held up by a hung thread, or the physics logs by a disk
// which doesn't answer: the run ends anyway
// what was logged last gets written, unless the log is held up by a hung thread, or the physics logs by a writer
// holding their files or a disk which doesn't answer: the run ends anyway, two seconds later at most
PhysicsLogs.flush_for(std::chrono::seconds{2});
StopLogService();
std::this_thread::sleep_for(std::chrono::milliseconds(250));