Skip to content

happy-eyeballs: Move platform code behind per-platform files - #910

Merged
zackees merged 2 commits into
masterfrom
facade/880-happy-eyeballs
Oct 16, 2026
Merged

zackees merged 2 commits into
masterfrom
facade/880-happy-eyeballs

Conversation

@zackees

@zackees zackees commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Refs #880 (part of #847).

Step 1 (this commit): characterization test test/cmocka/test_happy_eyeballs.c, C only, registered via tests.d/ (built where OBS::happy-eyeballs exists, ws2_32 on Windows):

  • IPv4 connect to a loopback listener: connect/timedwait return 0, the error code is 0, the server accepts the connection, and happy_eyeballs_get_remote_addr returns the address length (not a status);
  • IPv6 the same, skipped where ::1 does not resolve (AI_ADDRCONFIG drops it on hosts without a non-loopback IPv6 address, as in the Tier 2 container);
  • a refused port fails with an error code and message;
  • an unresolvable .invalid host fails (its error code is not pinned: it is errno, usually 0 on Linux, filed as bug: shared/happy-eyeballs: a failed name lookup reports errno instead of the getaddrinfo error (error code 0 on Linux) #903);
  • connect rejects NULL host, port 0 and NULL context.

Local: rust/tools/linux-validate/run.sh --repeat 5 --tests test_happy_eyeballs: 250/250 OFF and ON, 5 repeats each; ./lint ok.

Step 2: the move (happy-eyeballs: Move the Winsock/BSD-socket code into platform/<os>/): the 8 platform conditionals in happy-eyeballs.c/.h move into platform/windows/ and platform/posix/ (both blessed by #900's PLATFORM_TOKENS), each with:

  • happy-eyeballs-socket.h: socket types for the public header (SOCKET on POSIX);
  • happy-eyeballs-platform.h: GetSockError, GetAddrInfoErrorString (from happy-eyeballs: Report the getaddrinfo error for a failed lookup #918), snprintf/SHUT_RDWR/closesocket, and static inline he_platform_dns_blocked (the COMODO probe), he_platform_socket (WSASocket vs socket) and he_platform_socket_nosigpipe.

CMake puts the right directory on the include path ($<PLATFORM_ID:Windows>), and lists the headers with absolute paths: relative paths inside generator expressions are not converted (CMP0076), which broke consumers' configure on a first push. The shared files have no platform conditionals left (the __cplusplus and INVALID_SOCKET ones are not platform macros); ci/platform-ifdef-baseline.json drops both files.

Local: ci/platform_ifdef_ratchet.py ok; POSIX cc -fsyntax-only -std=gnu11 -Wall -Werror ok; ./lint ok; Tier 2 run.sh --repeat 3 --tests 'test_happy_eyeballs|test_rtmp_dbr_user_bitrate': 251/251 OFF and ON (both happy-eyeballs tests and the RTMP test that links it, 3 repeats each). ci-full is set so the Windows and macOS builds compile the moved code.

@zackees
zackees force-pushed the facade/880-happy-eyeballs branch from 8705d68 to 91c141b Compare October 15, 2026 23:34
@zackees zackees added the ci-full Run every CI job on this PR, including the release-gating OBS app builds and Flatpak label Oct 15, 2026
@zackees

zackees commented Oct 15, 2026

Copy link
Copy Markdown
Member Author

Pushed the facade move (91c141bbd, on top of the rebased characterization test). Note: my force-push replaced 8705d68ec ("style: Apply clang-format" on test_happy_eyeballs.c), which I had not seen. I checked: git diff 8705d68ec 91c141bbd -- test/cmocka/test_happy_eyeballs.c is empty, since my commit ran the same formatter on the same file, so that change is kept. Added ci-full so the Windows and macOS builds compile the moved code.

C only: test_happy_eyeballs connects over IPv4 (and IPv6 where ::1
resolves) to a loopback listener and checks the server accepts it,
pins get_remote_addr returning the address length, a refused port, an
unresolvable host and the invalid-argument checks. It must pass
unchanged before and after the facade move (#880). The resolve-failure
error code is left unpinned: it is errno, usually 0 on Linux (#903).

Refs #880
The 8 platform conditionals in happy-eyeballs.c and happy-eyeballs.h
move into platform/windows/ and platform/posix/, each with
happy-eyeballs-socket.h (socket types for the public header) and
happy-eyeballs-platform.h (GetSockError, snprintf, SHUT_RDWR,
closesocket, and static inline he_platform_dns_blocked (the COMODO
probe), he_platform_socket (WSASocket vs socket) and
he_platform_socket_nosigpipe). CMake puts the right directory on the
include path, so the shared files have no platform conditionals; the
test_happy_eyeballs passes before and after.

Refs #880
@zackees
zackees force-pushed the facade/880-happy-eyeballs branch from 91c141b to 3a9b49b Compare October 16, 2026 00:01
@zackees

zackees commented Oct 16, 2026

Copy link
Copy Markdown
Member Author

Rebased onto master after #918 merged: replaced head 91c141bbd with 3a9b49bcb (verified on the remote). #918's GetAddrInfoErrorString defines now live in the two happy-eyeballs-platform.h files. Also fixed the CMake configure error from the previous head (platform header paths are now absolute). Local Tier 2 251/251 OFF and ON.

@zackees
zackees marked this pull request as ready for review October 16, 2026 00:01
@zackees
zackees enabled auto-merge October 16, 2026 00:03
@zackees
zackees added this pull request to the merge queue Oct 16, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 16, 2026
@zackees
zackees added this pull request to the merge queue Oct 16, 2026
Merged via the queue into master with commit fd9f58e Oct 16, 2026
26 checks passed
@zackees
zackees deleted the facade/880-happy-eyeballs branch October 26, 2026 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-full Run every CI job on this PR, including the release-gating OBS app builds and Flatpak

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant