Skip to content

P2P connections minor issue during close - #19

Open
zenaror wants to merge 24 commits into
REONTeam:masterfrom
zenaror:dev
Open

P2P connections minor issue during close#19
zenaror wants to merge 24 commits into
REONTeam:masterfrom
zenaror:dev

Conversation

@zenaror

@zenaror zenaror commented Aug 28, 2026

Copy link
Copy Markdown

P2P: don't report low-level socket errors to the game either

Two previous commits already made recv_size == -2 (graceful remote close) silent for P2P calls.

This matches the behavior of a real Mobile Adapter over a phone line: there is no way to instantly know that the line dropped, so the game is expected to detect the failure through its own timeout instead

However, the other two error exits in command_data() were not consistent with that behavior:

  • A failed send() (rc < 0)
  • Any other recv() error (recv_size < 0), such as ECONNRESET from a P2P peer that closed abruptly

Both cases still raised an immediate Error Status, regardless of whether the connection was using P2P or internet mode.

This exposes exactly the same kind of low-level information that a phone-line call could not have provided to the game. It was also causing asymmetric behavior in two-machine P2P tests: one side could detect the other side hanging up immediately, while the other side would not.

That behavior depended only on whether the OS happened to send a FIN or an RST when the socket was closed, rather than on anything meaningful at the protocol level.

Both error paths now remain silent in P2P mode, consistent with the existing recv_size == -2 handling.

Additionally, command_wait_call_begin() did not defensively close a leftover p2p_conn, while command_tel_begin() already does so in the opposite direction. The existing comment in that function explicitly mentions this behavior:

"Close any connection created by command_wait_call"

Since mobile_cb_sock_open() requires the connection slot to already be closed, the same guard is now mirrored in command_wait_call_begin() for symmetry.


This PR also includes the mail port redirection #14

zenaror added 24 commits August 24, 2024 18:12
This reverts commit 093209a.
Two commits already made recv_size == -2 (graceful remote close)
silent for P2P calls, since a real Mobile Adapter over a phone line
has no way to instantly know the line dropped -- the game is meant to
notice via its own timeout instead (see "update P2P synchronisation").

The other two error exits in command_data() weren't consistent with
that: a failed send() (rc < 0) and any other recv() error
(recv_size < 0, e.g. ECONNRESET from a P2P peer that closed abruptly)
both still raised an immediate Error Status regardless of P2P/internet
mode. That's exactly the same kind of information a phone-line call
couldn't have given the game either, and it's what was letting one
side of a two-machine P2P test find out about the other side hanging
up immediately while the other side never did (depends only on
whether the OS happened to send a FIN or an RST at close time, not on
anything meaningful). Both paths now stay silent for P2P the same way,
consistent with the existing -2 handling.

Also: command_wait_call_begin() didn't defensively close a leftover
p2p_conn the way command_tel_begin() already does in the opposite
direction (that function's own comment says as much: "Close any
connection created by command_wait_call"). mobile_cb_sock_open()
requires the connection slot to already be closed, so mirrored the
same guard here for symmetry.
P2P: don't report low-level socket errors to the game either
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant