Skip to content

amiga: use native socket error accessors on classic AmigaOS - #23695

Closed
reinauer wants to merge 3 commits into
curl:masterfrom
reinauer:amiga-native-socket-errno
Closed

reinauer wants to merge 3 commits into
curl:masterfrom
reinauer:amiga-native-socket-errno

Conversation

@reinauer

@reinauer reinauer commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Classic AmigaOS builds using bsdsocket.library directly still read socket errors through libc errno. Those are not necessarily the same error channel. With the October 29 AmigaPorts newlib SDK, libc errno is shared between the GUI task and its pthread worker: a main-task libc call can replace the worker's EWOULDBLOCK before curl classifies a nonblocking receive.

Use Errno() for SOCKERRNO and SocketBaseTagList(SBTC_ERRNO) for SET_SOCKERRNO, keeping both operations on the native socket error channel. The setter evaluates its argument once. The guard excludes OS4, MorphOS, AROS and libc networking paths. This does not make libc errno thread-local or change application socket/AmiSSL task ownership.

Validation:

  • Current master plus this patch: full macOS build, curl-lint, and all 79 unittest tests passed.
  • Current cf-socket.c and curlx/wait.c cross-compiled with m68k GCC 16.2.1 and the validated classic-Amiga curl configuration.
  • Native AmigaOS regression on curl 8.23.0: a test hook pauses the worker immediately after real sread() returns EWOULDBLOCK, before curl reads SOCKERRNO; the main task assigns errno = ENOENT, then releases the worker. An idle live TCP connection is used, without sending an HTTP request.
baseline: global errno 35 -> 2; socket error 35 -> 35;
          curl=56 (CURLE_RECV_ERROR), OS_ERRNO=2
fixed:    global errno 0 -> 2; socket error 35 -> 35;
          curl=81 (CURLE_AGAIN), OS_ERRNO=0

Both native probes completed with their expected outcomes and zero failures. The repaired integration also passed WebSocket echo while a TLS handshake remained pending. These are emulator/guest results, not physical-hardware validation; the native runtime run used 8.23.0 with the same native accessors (its setter was an inline helper), not today's complete master. The SDK-specific interleaving harness is outside curl's portable suite, so the test method and exact outcomes are included here.

Direct bsdsocket.library calls do not have to use libc's errno storage.
In particular, classic newlib can share errno between the GUI task and
a network worker. A libc call on the GUI task can then replace a socket
EWOULDBLOCK before curl classifies it, turning a retry into a receive
failure even though the native socket error is still EWOULDBLOCK.

Read SOCKERRNO through Errno() and set it with SocketBaseTagList using
SBTC_ERRNO. Keep both operations on the native socket error channel.
Limit this to the classic direct-bsdsocket path; leave the other Amiga
variants and libc networking paths unchanged.
Comment thread lib/curl_setup.h Resolved
Put the do block on a continuation line and indent its body to match
the surrounding multiline macro style. Socket errors behave as before.
Comment thread lib/curl_setup.h Resolved
Copy the review suggestion exactly, including its continuation spacing.
@vszakats

Copy link
Copy Markdown
Member

LGTM now!

@bagder bagder closed this in 6547588 Nov 2, 2026
@bagder

bagder commented Nov 2, 2026

Copy link
Copy Markdown
Member

Thanks, merged!

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants