Skip to content

facade: shared/happy-eyeballs: move 8 platform conditionals into happy-eyeballs-<os> files #880

Closed

Description

@zackees

Part of #847.

Winsock vs BSD sockets differences in the Happy Eyeballs connector.

Class totals: (a) movable 8, (b) stays - public header 0, (c) Rust-ported 0. Total: 8. Line numbers on origin/master.

file:line macro branch class proposed function / target
shared/happy-eyeballs/happy-eyeballs.c:31 _WIN32 winsock2 includes + MSVC pragma / snprintf alias a happy-eyeballs-sock.h dispatching to -windows.h / -posix.h
shared/happy-eyeballs/happy-eyeballs.c:32 _MSC_VER disable 4996 warning a inside happy-eyeballs-windows.h
shared/happy-eyeballs/happy-eyeballs.c:38 _MSC_VER #define snprintf _snprintf a inside happy-eyeballs-windows.h
shared/happy-eyeballs/happy-eyeballs.c:169 _WIN32 COMODO sandbox: gethostbyname("localhost") probe a he_platform_dns_probe() in happy-eyeballs-windows.c
shared/happy-eyeballs/happy-eyeballs.c:343 !_WIN32 && SO_NOSIGPIPE setsockopt SO_NOSIGPIPE (BSD/macOS) a he_socket_set_nosigpipe(fd) in -posix.c
shared/happy-eyeballs/happy-eyeballs.c:406 _WIN32 WSASocket overlapped vs socket() a he_socket_create(family)
shared/happy-eyeballs/happy-eyeballs.c:626 _WIN32 SHUT_RDWR=SD_BOTH vs closesocket=close a in -windows.h / -posix.h
shared/happy-eyeballs/happy-eyeballs.h:37 _WIN32 include winsock2/ws2tcpip vs sys/socket a happy-eyeballs-sock.h

Classes: (a) movable behind per-platform files; (b) public-header ABI/export/type selection, stays; (c) already replaced by the Rust port (platform code isolated in src/platform/). Macro column abbreviates the #if expression; ! means negated, elif means an #elif line.

Test approach: No existing tests; add a characterization test (loopback connect against a local server) on Tier 2 Linux plus Windows native build via ci-full.

Each move is one function per facade entry, mechanical, so upstream merges stay manageable; the ratchet baseline (step 1) drops by the moved count.

Activity

  1. zackees commented on Oct 15, 2026

    @zackees
    MemberAuthor

    Claiming: shared/happy-eyeballs facade.

    Plan (one PR, RED then GREEN):

    1. Characterization test first: test_happy_eyeballs (cmocka, Tier 2), loopback connect to a local listener over IPv4 and IPv6, a refused port, and an unresolvable host. It must pass before and after the move.
    2. Move the 8 conditionals. The issue suggests a happy-eyeballs-sock.h that dispatches to -windows.h/-posix.h, but that dispatcher would itself be an #ifdef in a shared file, which ci: ratchet lint for platform conditionals in shared C/C++ (#847 step 1) #848's policy bans. Instead CMake picks the platform half: shared code includes he-platform.h and calls he_platform_*(); platform/windows/ and platform/posix/ each hold he-platform.h + he-platform.c, and shared/happy-eyeballs/CMakeLists.txt adds the right directory and source per OS. happy-eyeballs.h's socket-type include moves the same way. Shared files end with zero platform conditionals.
    3. ci-full label so the Windows and macOS builds run.

    @zackees (#848): will */platform/windows/ and */platform/posix/ be in the blessed-directory allowlist, or do you want -windows/-nix file names instead? I'll follow whichever #848 lands with.

  2. added
    claimed
    on Oct 15, 2026
  3. zackees commented on Oct 15, 2026

    @zackees
    MemberAuthor

    Naming answered by #900 (the merged #848 ratchet): a path is blessed when any of its tokens is a platform word, and windows and posix are both in PLATFORM_TOKENS, so shared/happy-eyeballs/platform/windows/ and platform/posix/ work as planned. Baseline today: happy-eyeballs.c 7, happy-eyeballs.h 1; the move takes both to 0 and drops them from ci/platform-ifdef-baseline.json. Starting the move on #910 once #918 (#903) merges, so the moved code carries that fix.

  4. zackees commented on Oct 16, 2026

    @zackees
    MemberAuthor

    Done: #910 moved the 8 platform conditionals in shared/happy-eyeballs into platform/windows/ and platform/posix/ (happy-eyeballs-socket.h for the public header's socket types, happy-eyeballs-platform.h for the rest), with CMake picking the directory. The shared files have none left and are out of the #848 baseline. test_happy_eyeballs (characterization, same PR) passed before and after, on Tier 2 Linux and in the ci-full Windows/macOS builds.

    Found along the way and fixed: #903 (a failed lookup reported errno, i.e. 0 on Linux), via #918. Nothing left on this item.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    claimed

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions