Implement accept4 - #2779
Open
emkey1 wants to merge 1 commit into
Open
Conversation
accept4 is wired to syscall_stub, so it returns ENOSYS. Go's net package uses it for every accepted connection, which is what ish-app#1889 and ish-app#2553 both report: "accept tcp [::]:9999: accept4: function not implemented". It is accept plus two flags that apply to the accepted fd: SOCK_CLOEXEC sets FD_CLOEXEC on it and SOCK_NONBLOCK sets O_NONBLOCK on it, neither touching the listener. Any other flag is EINVAL. The socketcall entry is filled in to match. Verified against real Linux with the same static i386 binary, over a loopback TCP connection: before after / real Linux accept4(flags=0) ENOSYS connected fd SOCK_CLOEXEC sets FD_CLOEXEC ENOSYS set listener FD_CLOEXEC untouched ok ok SOCK_NONBLOCK sets O_NONBLOCK ENOSYS set nonblocking accepted fd reads ENOSYS EAGAIN peer address filled in ENOSYS AF_INET bogus flags ENOSYS EINVAL
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.
accept4is wired tosyscall_stub, so it returns ENOSYS.Go's net package uses it for every accepted connection, which is what #1889 and #2553 both report:
Go has no fallback to plain
accept, so a Go server fails on its first connection.What it does
acceptplus two flags that apply to the accepted fd:SOCK_CLOEXECsetsFD_CLOEXECon it andSOCK_NONBLOCKsetsO_NONBLOCKon it, neither touching the listener. Any other flag is EINVAL. The socketcall entry is filled in to match.Verification
Same static i386 binary run on real Linux and on iSH, over a loopback TCP connection:
accept4(flags=0)SOCK_CLOEXECsetsFD_CLOEXECFD_CLOEXECuntouchedSOCK_NONBLOCKsetsO_NONBLOCKReproduced on the Alpine 3.19.0 rootfs the App Store build downloads (
ROOTFS_URLinapp/iSH.xcconfig), against master 7864dd6.python3from the mirrored 3.19 repo also reaches this path: CPython callsaccept4(SOCK_CLOEXEC)on Linux, and the log showsstub syscall 364on each accept. CPython does fall back to plainaccept()on ENOSYS, so it keeps working; the difference from Go is the fallback, not the call.