unix: consolidate tcp and udp bind error
OSX, other BSDs and SunoS fail with EAFNOSUPPORT when binding a socket created with AF_INET to an AF_INET6 address or vice versa. PR-URL: https://github.com/libuv/libuv/pull/407 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
parent
af20bb6830
commit
d377435b5e
@ -121,8 +121,13 @@ int uv__tcp_bind(uv_tcp_t* tcp,
|
||||
#endif
|
||||
|
||||
errno = 0;
|
||||
if (bind(tcp->io_watcher.fd, addr, addrlen) && errno != EADDRINUSE)
|
||||
if (bind(tcp->io_watcher.fd, addr, addrlen) && errno != EADDRINUSE) {
|
||||
if (errno == EAFNOSUPPORT)
|
||||
/* OSX, other BSDs and SunoS fail with EAFNOSUPPORT when binding a
|
||||
* socket created with AF_INET to an AF_INET6 address or vice versa. */
|
||||
return -EINVAL;
|
||||
return -errno;
|
||||
}
|
||||
tcp->delayed_error = -errno;
|
||||
|
||||
if (addr->sa_family == AF_INET6)
|
||||
|
||||
@ -321,6 +321,10 @@ int uv__udp_bind(uv_udp_t* handle,
|
||||
|
||||
if (bind(fd, addr, addrlen)) {
|
||||
err = -errno;
|
||||
if (errno == EAFNOSUPPORT)
|
||||
/* OSX, other BSDs and SunoS fail with EAFNOSUPPORT when binding a
|
||||
* socket created with AF_INET to an AF_INET6 address or vice versa. */
|
||||
err = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user