tcp_echo currently accepts one connection, echoes data until EOF, then exits. It should serve multiple concurrent connections by spawning a new OS thread per accepted connection.
Current state
- Program:
userspace/src/bin/tcp_echo.rs
- Listens on port 1234, calls
listener.accept() once, echoes in a loop, then exits.
- System test:
system-tests/src/tests/net.rs::tcp_echo — opens one connection and verifies two round-trip messages.
Required changes
userspace/src/bin/tcp_echo.rs
Change the main loop to:
- Call
listener.accept() in a loop.
- For each accepted connection, spawn a new OS thread (via
std::thread::spawn) to handle it.
- The per-connection thread reads until EOF and echoes back each chunk, then exits.
The program should keep running indefinitely (it is a server), so the main thread only loops on accept.
New system test
Add a test tcp_echo_concurrent in system-tests/src/tests/net.rs that:
- Starts Solaya with networking and launches
tcp_echo.
- Opens 20 simultaneous TCP connections from the test host.
- Sends a unique message on each connection concurrently (use
tokio::join! or FuturesUnordered).
- Asserts that each connection receives its own message back.
- Closes all connections.
Acceptance criteria
cargo nextest run --release --manifest-path system-tests/Cargo.toml --target x86_64-unknown-linux-gnu tcp_echo passes (existing single-connection test).
- New
tcp_echo_concurrent test passes with all 20 connections getting correct echo replies.
- No kernel panic under the concurrent load.
tcp_echocurrently accepts one connection, echoes data until EOF, then exits. It should serve multiple concurrent connections by spawning a new OS thread per accepted connection.Current state
userspace/src/bin/tcp_echo.rslistener.accept()once, echoes in a loop, then exits.system-tests/src/tests/net.rs::tcp_echo— opens one connection and verifies two round-trip messages.Required changes
userspace/src/bin/tcp_echo.rsChange the main loop to:
listener.accept()in a loop.std::thread::spawn) to handle it.The program should keep running indefinitely (it is a server), so the main thread only loops on
accept.New system test
Add a test
tcp_echo_concurrentinsystem-tests/src/tests/net.rsthat:tcp_echo.tokio::join!orFuturesUnordered).Acceptance criteria
cargo nextest run --release --manifest-path system-tests/Cargo.toml --target x86_64-unknown-linux-gnu tcp_echopasses (existing single-connection test).tcp_echo_concurrenttest passes with all 20 connections getting correct echo replies.