-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add support for accept and accept4 #287
Conversation
Side note: while writing test code, I encountered:
I hope, this is just me using |
@sunfishcode This is the feature I mentioned on the phone. We should consider this a blocker before starting the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good!
When adding new files, such as this accept.c, we should add them in libc-bottom-half/sources, since they aren't derived from cloudlibc. See below for how to resolve the common/errno.h header:
Since the socket address of the accepted socket is unknown, all bytes are set to zero and the length is truncated to the size of the generic `struct sockaddr`. Signed-off-by: Harald Hoyer <[email protected]>
Looks good! |
int accept4(int socket, struct sockaddr *restrict addr, socklen_t *restrict addrlen, int flags) { | ||
int ret = -1; | ||
|
||
if (flags & ~(SOCK_NONBLOCK | SOCK_CLOEXEC)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose the rationale for validating, but dropping the only flag besides nonblock is because it isn't in wasi, right? https://github.com/WebAssembly/WASI/blob/main/phases/snapshot/docs.md#fdflags cc @deadprogram who's implementing tinygo tinygo-org/tinygo#2748 🎖️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry tagged wrong person meant @rvolosatovs 😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this behavior is not relevant for the TinyGo implementation, since this is a wrapper for sock_accept
, whereas in the TinyGo PR we call it directly via WASI
Since the socket address of the accepted socket is unknown,
all bytes are set to zero and the length is truncated to the size
of the generic
struct sockaddr
.Fixes: #284
Supersedes: #286
Signed-off-by: Harald Hoyer [email protected]