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

fix(physicslog): a log whose file can't be written keeps its lines and header, and the writer is stopped once on every way out

A failed write put its lines back, ahead of those since, so a file held by
another program for a while gets its header and every line once it can be
written; up to 4 MB kept per log. Stopping is joined once, and not from the
writer's own thread. main stops the logs after an error it caught too, and the
test watchdog flushes with a time limit, so a disk that doesn't answer doesn't
keep the run from ending.
This commit is contained in:
maj00r
2026-11-15 23:32:38 +01:00
parent 7b7529e24e
commit 7547e6bf07
5 changed files with 134 additions and 18 deletions

View File

@@ -262,8 +262,9 @@ 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
PhysicsLogs.flush();
// 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
PhysicsLogs.flush_for(std::chrono::seconds{2});
StopLogService();
std::this_thread::sleep_for(std::chrono::milliseconds(250));
std::_Exit(exit_code());