mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-14 15:09:09 +00:00
Fix test failure on Windows
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
This commit is contained in:
parent
24d79599cc
commit
f40f97bd07
4 changed files with 65 additions and 20 deletions
|
@ -50,10 +50,19 @@ ssize_t recvfrom(int fd, void *buf, size_t size, uint32_t flags,
|
|||
sockaddr2linux(opt_out_srcaddr);
|
||||
}
|
||||
return got;
|
||||
} else if (__isfdkind(fd, kFdSocket)) {
|
||||
return sys_recvfrom_nt(&g_fds.p[fd], (struct iovec[]){{buf, size}}, 1,
|
||||
flags, opt_out_srcaddr, opt_inout_srcaddrsize);
|
||||
} else {
|
||||
return ebadf();
|
||||
if (__isfdopen(fd)) {
|
||||
if (__isfdkind(fd, kFdSocket)) {
|
||||
return sys_recvfrom_nt(&g_fds.p[fd], (struct iovec[]){{buf, size}}, 1,
|
||||
flags, opt_out_srcaddr, opt_inout_srcaddrsize);
|
||||
} else if (__isfdkind(fd, kFdFile) && !opt_out_srcaddr) { /* socketpair */
|
||||
if (flags) return einval();
|
||||
return sys_read_nt(&g_fds.p[fd], (struct iovec[]){{buf, size}}, 1, -1);
|
||||
} else {
|
||||
return enotsock();
|
||||
}
|
||||
} else {
|
||||
return ebadf();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue