Revert "Polyfill ENOTSOCK in getsockname() and getpeername()"

This reverts commit 925219bdf3.
This commit is contained in:
Justine Tunney 2023-07-24 03:09:43 -07:00
parent 925219bdf3
commit 4fb6cbc1fe
No known key found for this signature in database
GPG key ID: BE714B4575D6E328

View file

@ -39,21 +39,21 @@ static int __getsockpeername(int fd, struct sockaddr *out_addr,
uint32_t size = sizeof(ss); uint32_t size = sizeof(ss);
if (IsWindows()) { if (IsWindows()) {
if (!__isfdopen(fd)) { if (__isfdkind(fd, kFdSocket)) {
rc = ebadf(); if ((rc = impl_win32(g_fds.p[fd].handle, &ss, &size))) {
} else if (!__isfdkind(fd, kFdSocket)) { if (impl_win32 == __sys_getsockname_nt &&
rc = enotsock(); WSAGetLastError() == WSAEINVAL) {
} else if ((rc = impl_win32(g_fds.p[fd].handle, &ss, &size))) { // The socket has not been bound to an address with bind, or
if (impl_win32 == __sys_getsockname_nt && // ADDR_ANY is specified in bind but connection has not yet
WSAGetLastError() == WSAEINVAL) { // occurred. -MSDN
// The socket has not been bound to an address with bind, or ss.ss_family = ((struct SockFd *)g_fds.p[fd].extra)->family;
// ADDR_ANY is specified in bind but connection has not yet rc = 0;
// occurred. -MSDN } else {
ss.ss_family = ((struct SockFd *)g_fds.p[fd].extra)->family; rc = __winsockerr();
rc = 0; }
} else {
rc = __winsockerr();
} }
} else {
rc = ebadf();
} }
} else { } else {
rc = impl_sysv(fd, &ss, &size); rc = impl_sysv(fd, &ss, &size);