Fix socket() EPROTONOSUPPORT fallback on MacOS

This commit is contained in:
Justine Tunney 2023-08-22 14:34:37 -07:00
parent 58ef4e6df8
commit 4c74f09393
No known key found for this signature in database
GPG key ID: BE714B4575D6E328

View file

@ -25,7 +25,8 @@ int sys_socket(int family, int type, int protocol) {
int sock, tf, e = errno;
tf = SOCK_CLOEXEC | SOCK_NONBLOCK;
sock = __sys_socket(family, type, protocol);
if (sock == -1 && (type & tf) && (errno == EINVAL || errno == EPROTOTYPE)) {
if (sock == -1 && (type & tf) &&
(errno == EINVAL || errno == EPROTOTYPE || errno == EPROTONOSUPPORT)) {
errno = e; // XNU/RHEL5/etc. don't support flags; see if removing helps
sock = __fixupnewsockfd(__sys_socket(family, type & ~tf, protocol), type);
}