Set SO_REUSEPORT on multicast input sockets for Apple platforms#6471
Open
keskinonur wants to merge 1 commit into
Open
Set SO_REUSEPORT on multicast input sockets for Apple platforms#6471keskinonur wants to merge 1 commit into
keskinonur wants to merge 1 commit into
Conversation
OpenAndBindInputSocket() only enabled SO_REUSEPORT for QNX (eProsima#272, eProsima#350). On Darwin, SO_REUSEADDR alone is not enough for two processes to share a UDP multicast port: the second bind fails with EADDRINUSE, the failure is not surfaced, and that DomainParticipant never receives SPDP multicast. Extend the existing QNX conditional to __APPLE__ in UDPv4 and UDPv6 transports. Linux intentionally unchanged: SO_REUSEPORT there load-balances datagrams instead of duplicating delivery. Signed-off-by: Onur Keskin <onur@bilims.com>
keskinonur
force-pushed
the
bugfix/macos-multicast-reuseport
branch
from
July 9, 2026 21:08
157d931 to
7368257
Compare
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.
Description
OpenAndBindInputSocket()setsSO_REUSEPORTon multicast input sockets only for QNX (#272, #350). Apple platforms (macOS/Darwin) have the same BSD requirement: withSO_REUSEADDRalone, the second process on a host that binds the SPDP multicast port getsEADDRINUSE, the failure is swallowed, and that participant never receives discovery multicast — it silently sees an empty domain while unicast ports bind fine.This PR extends the existing QNX conditional to
__APPLE__in bothUDPv4Transport.cppandUDPv6Transport.cpp.Linux intentionally unchanged:
SO_REUSEPORTon Linux load-balances datagrams across sockets rather than duplicating them, which would break multi-process discovery instead of fixing it.Fixes #6470
Motivation
Real-world failure: two librealsense processes using an Intel RealSense D555 Ethernet camera on macOS — whichever process binds the multicast port second never discovers the camera. Socket-level repro (no DDS needed) in the linked issue shows
EADDRINUSEfor the second bind withoutSO_REUSEPORTand full duplicate delivery to both sockets with it.Verified on macOS / Apple Silicon with a live D555 (RealSense PoE camera): without this patch a second concurrently-running process never discovers the remote participant; with it, second-process discovery works.
Full disclosure: our downstream stack also serializes near-simultaneous participant creation — a separate, rarer effect noted in #6470 as out of scope; an end-to-end 22/22 dual-process figure we report elsewhere was measured with both measures in place. The socket-level repro in the issue isolates what this patch alone fixes.
Contributor Checklist
Signed-off-by: Onur Keskin <keskinonur@me.com>)Backport
Please consider backporting to maintained 2.x branches (librealsense currently pins
v2.10.4/v2.10.4-realsense). The change is a one-line platform guard extension plus a short comment.