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

6 Commits

Author SHA1 Message Date
maj00r
99b93abd64 fix(physicslog): nothing that goes wrong in the writing ends the simulator; a name in 1250 makes a path on a Windows set to UTF-8
The writer's thread called flush() with nothing around it, so an exception leaving write() ended the
process with std::terminate, with no message. One that happens: the file of a log was made a
std::filesystem::path of the vehicle's name, which MSVC converts in the code page of the system and
throws for bytes not of it; on a Windows with "Use Unicode UTF-8 for worldwide language support" a
vehicle named in 1250, as the sceneries have them (0xB3 for ł), isn't UTF-8.

- the file of a log is made of the name with MultiByteToWideChar without MB_ERR_INVALID_CHARS: the same
  file as before for every name of the code page, U+FFFD for the bytes not of it instead of a throw.
  Elsewhere the bytes are the name of the file as they were
- a log whose writing throws for any other reason (memory) is kept for the next try as one whose file
  can't be written, and the other logs are written still
- the thread, flush_for() and stop() write through flush_safely(), which lets nothing out: what was taken
  for a writing failing as a whole is lost and told in the log, the next writing goes on
- the messages name the file by the bytes of the name, not by path::string(), which converts back

Tests: a log which can't be written doesn't keep the others from theirs; a vehicle named in 1250 has its
log, read back by physicslog_writer::file().

Reported in the review of #385.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 12:47:22 +01:00
maj00r
423d49b42c fix(physicslog): every stop asked wakes the writer, the one from itself too; no psyche for a driver of no vehicle 2026-11-16 02:12:01 +01:00
maj00r
94b7c7f01b fix(physicslog): the writer's destructor throws nothing, its wait a plain condition variable woken to stop; a driver of no vehicle controls nothing 2026-11-16 02:08:04 +01:00
maj00r
043b9fb2f0 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.
2026-11-15 23:38:24 +01:00
maj00r
7547e6bf07 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.
2026-11-15 23:32:38 +01:00
maj00r
03a3b4c09a feat(physicslog): the logs written every two seconds by a thread of their own, no file kept open; the black box's tapes as it goes
"physicslog yes" kept the .dat of every vehicle with a driver open for the whole run and flushed it twenty
times a second from the simulation's thread: some 580 open files on Tomaszewo. The lines are kept now and a
thread of their own writes them every two seconds, each file opened only for the moment it is written to.
The files, their lines and their text mode stay as they were.

- The black box, with the physics logs off, writes the tapes of the user's vehicles through the same
  writer as it goes, not at the end. A log begins when the user is first in the vehicle and goes on
  while the user looks around outside, until another vehicle is taken; back in it, the log goes on after
  the gap. The vehicle's own driver keeps the log only if it is the primary one, as a passive one's clock
  stands still; otherwise the driver of its train does.
- What is kept is written when the simulator closes, after the black box, at the end of a test run, and
  when the test watchdog ends a run. A crash loses the last two seconds.
- On Tomaszewo with the black box alone, the one tape grows every two seconds. With "physicslog yes", the
  581 logs grow and the simulator holds as many handles as without them; writing them takes the thread
  about 1.9 s, which the closing waits for once.
2026-11-14 00:48:17 +01:00