fix(simulation): address PR #37 review — doc corrections, race fix, marker cleanup
Hoshe review (4 items): - types.rs: doc comment "Current: 6" → "Current: 9" - dialogue.rs: walk-away doc duplicated numbering (items 4-5 were 2-3) - test_world/mod.rs: comment "Reset plates at 49-51" → "49-55" - content_scaling.rs: magic number 51 → constants::RESET_PLATE_STABLE_IDS.1 Tyre review (3 items): - knowledge/types.rs: guard comments on decrement() floor at Hostile - input.rs: TeleportToHub now clears ConfrontationDelivered marker - content_scaling.rs: same magic number fix (covered above) Additional: - content_runtime.rs: barrier-based shutdown handshake fixes TCP RST race condition under parallel test execution - dialogue_room.rs: clippy type_complexity allow on NPCS tuple array Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
use bevy_app::prelude::*;
|
||||
use std::net::{TcpListener, TcpStream};
|
||||
use std::path::PathBuf;
|
||||
use std::sync::{Arc, Barrier};
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
@@ -51,6 +52,11 @@ fn content_runtime_boot_tick_10_snapshot() {
|
||||
let listener = TcpListener::bind("127.0.0.1:0").expect("bind listener");
|
||||
let server_addr = listener.local_addr().expect("get local addr");
|
||||
|
||||
// Barrier keeps the server thread alive until the client has finished
|
||||
// reading all snapshots, preventing a TCP RST race under parallel execution.
|
||||
let barrier = Arc::new(Barrier::new(2));
|
||||
let server_barrier = barrier.clone();
|
||||
|
||||
// Server thread: full plugin stack with real content
|
||||
let server_handle = thread::spawn(move || {
|
||||
let bridge = TcpBridge::accept_on(listener).expect("accept connection");
|
||||
@@ -96,6 +102,9 @@ fn content_runtime_boot_tick_10_snapshot() {
|
||||
for _ in 0..10 {
|
||||
app.update();
|
||||
}
|
||||
|
||||
// Wait for client to finish reading before dropping the TCP socket
|
||||
server_barrier.wait();
|
||||
});
|
||||
|
||||
// Client: connect with read timeout and receive 10 snapshots
|
||||
@@ -129,6 +138,9 @@ fn content_runtime_boot_tick_10_snapshot() {
|
||||
drop(reader);
|
||||
drop(writer);
|
||||
|
||||
// Signal server thread that client is done reading
|
||||
barrier.wait();
|
||||
|
||||
// Server thread must not have panicked
|
||||
server_handle
|
||||
.join()
|
||||
|
||||
Reference in New Issue
Block a user