refactor(server): stop branching on errno after accept/recv/send#5
Conversation
The 42 subject forbids using errno to drive control flow after the non-blocking I/O syscalls. acceptClient/handleClientInput/ handleClientOutput each inspected errno (EAGAIN/EWOULDBLOCK) to decide whether to log or disconnect. Removed: - accept() < 0 -> return (silent; no errno, no log) - recv() <= 0 -> disconnect only on == 0 (orderly close) - send() < 0 -> return Real socket errors (RST/ECONNRESET) are handled by the EPOLLERR|EPOLLHUP branch in run(); as a bonus this removes a latent false-positive disconnect on EINTR. Characterization test added (RobustnessTest.AbruptDisconnectViaRST): forces a real RST via SO_LINGER and proves in black box that the nick is released (client torn down). Green before and after the refactor. Note: which branch tears down an RST client is timing-dependent before this change (EPOLLIN+errno may win the race over EPOLLERR|HUP). After this change EPOLLERR|HUP handles it consistently, same iteration. Do not assume EPOLLERR|HUP alone covered RST prior to this commit. Suite: 139/139.
|
Closes #4 ProblemThe event loop used Change
Real socket errors (RST/ Two files only: Verification
Note for future event-loop work (please keep in the history)Which branch reaps an RST client is timing-dependent before this change: What I'd like you to validate
|
The 42 subject forbids using errno to drive control flow after the non-blocking I/O syscalls. acceptClient/handleClientInput/ handleClientOutput each inspected errno (EAGAIN/EWOULDBLOCK) to decide whether to log or disconnect. Removed:
Real socket errors (RST/ECONNRESET) are handled by the EPOLLERR|EPOLLHUP
branch in run(); as a bonus this removes a latent false-positive
disconnect on EINTR.
Characterization test added (RobustnessTest.AbruptDisconnectViaRST): forces a real RST via SO_LINGER and proves in black box that the nick is released (client torn down). Green before and after the refactor.
Note: which branch tears down an RST client is timing-dependent before this change (EPOLLIN+errno may win the race over EPOLLERR|HUP). After this change EPOLLERR|HUP handles it consistently, same iteration. Do not assume EPOLLERR|HUP alone covered RST prior to this commit.
Suite: 139/139.