-
-
Notifications
You must be signed in to change notification settings - Fork 698
Feature/sendmsg #148
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
Feature/sendmsg #148
Conversation
…ple struct containing two in_addr objects)
…32_t (the original type is socklen_t and is not signed). Added implementation of recvmsg
…ng the function to return EINVAL on BSD/MacOS for non-connected sockets
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.
Looks good, with two minor nits. Very happy to see the unit test. Thank you for sending this!
test/libc/sock/sendrecvmsg_test.c
Outdated
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ | ||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ | ||
╞══════════════════════════════════════════════════════════════════════════════╡ | ||
│ Copyright 2021 │ |
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.
Please edit this line.
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.
Hmm I copied the header from the socketpair test tha Allison wrote... I removed her name but I forgot to add your...
changed.
test/libc/sock/sendrecvmsg_test.c
Outdated
msg.msg_iovlen = 1; | ||
ASSERT_EQ(hwLen, recvmsg(fd[1], &msg, 0)); | ||
|
||
ASSERT_EQ(0, memcmp(&(((char *)(msg.msg_iov[0].iov_base))[0]), hello, strlen(hello))); |
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.
Try changing malloc(20)
to gc(xcalloc(20))
. In that case, you can delete the null check and these two lines can simply be EXPECT_STREQ("helloworld", msg.msg_iov[0].iov_base);
. You'll need these too of course:
#include "libc/runtime/gc.internal.h"
#include "libc/x/x.h"
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.
LGTM
The send{,to,msg} and recv{,from,msg} functions have been updated to delegate to WriteFile and ReadFile when appropriate, due to the fact that socketpair(AF_UNIX) is implemented using kFdFile. Thanks @fabriziobertocci for writing the test that caught this. See #148 and #122
Added implementation and unit test for sendmsg() and recvmsg().
Tested on Linux, Mac and Windows.