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:
Justine Tunney 2021-04-07 23:36:05 -07:00
parent 24d79599cc
commit f40f97bd07
4 changed files with 65 additions and 20 deletions

View file

@ -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();
}
}
}