mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 14:58:30 +00:00
Fix some more socket bugs
- The functions that return a sockaddr now do so the same way the Linux Kernel does across platforms, e.g. getpeername(), accept4() - Socket system calls on Windows will now only check for interrupts when a blocking operation needs to be performed. - Write tests for recvfrom() system call
This commit is contained in:
parent
ac92f25296
commit
0ba3199915
49 changed files with 347 additions and 352 deletions
|
@ -44,18 +44,24 @@
|
|||
int accept4(int fd, struct sockaddr *out_addr, uint32_t *inout_addrsize,
|
||||
int flags) {
|
||||
int rc;
|
||||
char addrbuf[72];
|
||||
struct sockaddr_storage ss = {0};
|
||||
BEGIN_CANCELLATION_POINT;
|
||||
|
||||
if (!out_addr || !inout_addrsize ||
|
||||
(IsAsan() && !__asan_is_valid(out_addr, *inout_addrsize))) {
|
||||
rc = efault();
|
||||
} else if (!IsWindows()) {
|
||||
rc = sys_accept4(fd, out_addr, inout_addrsize, flags);
|
||||
} else if (__isfdkind(fd, kFdSocket)) {
|
||||
rc = sys_accept_nt(&g_fds.p[fd], out_addr, inout_addrsize, flags);
|
||||
if (IsWindows()) {
|
||||
if (__isfdkind(fd, kFdSocket)) {
|
||||
rc = sys_accept_nt(g_fds.p + fd, &ss, flags);
|
||||
} else {
|
||||
rc = ebadf();
|
||||
}
|
||||
} else {
|
||||
rc = ebadf();
|
||||
rc = sys_accept4(fd, &ss, flags);
|
||||
}
|
||||
|
||||
if (rc != -1) {
|
||||
if (IsBsd()) {
|
||||
__convert_bsd_to_sockaddr(&ss);
|
||||
}
|
||||
__write_sockaddr(&ss, out_addr, inout_addrsize);
|
||||
}
|
||||
|
||||
END_CANCELLATION_POINT;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue