ext/libuv/src/unix/tcp.c in libuv-0.12.2 vs ext/libuv/src/unix/tcp.c in libuv-0.12.3
- old
+ new
@@ -61,10 +61,14 @@
unsigned int addrlen,
unsigned int flags) {
int err;
int on;
+ /* Cannot set IPv6-only mode on non-IPv6 socket. */
+ if ((flags & UV_TCP_IPV6ONLY) && addr->sa_family != AF_INET6)
+ return -EINVAL;
+
err = maybe_new_socket(tcp,
addr->sa_family,
UV_STREAM_READABLE | UV_STREAM_WRITABLE);
if (err)
return err;
@@ -87,12 +91,15 @@
#endif
errno = 0;
if (bind(tcp->io_watcher.fd, addr, addrlen) && errno != EADDRINUSE)
return -errno;
-
tcp->delayed_error = -errno;
+
+ if (addr->sa_family == AF_INET6)
+ tcp->flags |= UV_HANDLE_IPV6;
+
return 0;
}
int uv__tcp_connect(uv_connect_t* req,
@@ -153,11 +160,11 @@
sock,
UV_STREAM_READABLE | UV_STREAM_WRITABLE);
}
-int uv_tcp_getsockname(uv_tcp_t* handle,
+int uv_tcp_getsockname(const uv_tcp_t* handle,
struct sockaddr* name,
int* namelen) {
socklen_t socklen;
if (handle->delayed_error)
@@ -175,10 +182,10 @@
*namelen = (int) socklen;
return 0;
}
-int uv_tcp_getpeername(uv_tcp_t* handle,
+int uv_tcp_getpeername(const uv_tcp_t* handle,
struct sockaddr* name,
int* namelen) {
socklen_t socklen;
if (handle->delayed_error)