Handle macOS EINVAL when enabling TCP_NODELAY on outbound TCP sockets - #1161
Merged
Conversation
Agent-Logs-Url: https://github.com/zeromq/netmq/sessions/839215c1-545a-4f5c-8937-94397dcbaed6 Co-authored-by: drewnoakes <350947+drewnoakes@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix failing GitHub Actions job macos
Handle macOS May 24, 2026
EINVAL when enabling TCP_NODELAY on outbound TCP sockets
drewnoakes
approved these changes
May 24, 2026
drewnoakes
marked this pull request as ready for review
May 24, 2026 12:16
follesoe
added a commit
to BluEye-Robotics/netmq
that referenced
this pull request
Jul 20, 2026
…tener Problem: a peer that connects and immediately resets the connection can kill the whole process. When the RST lands between the proactor completing an accept and InCompleted applying socket options to the accepted socket, the option calls throw (EINVAL on macOS) on the proactor thread, where nothing catches the exception. Solution: treat setup failure as a failed accept, the way libzmq treats tune_socket failure: dispose the accepted socket, raise EventAcceptFailed and keep accepting. The guarded region includes the StreamEngine construction, whose constructor also touches the socket (send/receive buffer sizes). The monitor event reports ConnectionReset rather than mapping the raw error through ToErrorCode, which Debug.Asserts on unmapped values. Accept-side sibling of the outbound-socket fix in zeromq#1161. Adds a regression test that floods a listener with immediately-reset connects and asserts it stays alive and accepting; without the fix it crashes the test host 12/12 times on macOS arm64. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This was referenced Aug 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The macOS CI job was aborting during the test run because the test host crashed in
TcpConnector.OutCompletedwhile enablingNoDelayon a socket that had just connected. On macOS, this path can surface asSocketException(SocketError.InvalidArgument)rather than theArgumentExceptionthe code already tolerated.Root cause
TcpConnector.OutCompletedalready treatedNoDelaysetup as best-effort on macOS, but only forArgumentException.SocketExceptionwithInvalidArgumentfor the same transient condition.Change
m_s.NoDelay = trueto also ignore:SocketExceptionwhenSocketErrorCode == SocketError.InvalidArgumentImpact
TCP_NODELAYas opportunistic during this narrow connection window.