Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
update libuv to c0e7044862
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Zinkovsky committed Feb 22, 2012
1 parent 634b4de commit 35c1f68
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 6 deletions.
4 changes: 4 additions & 0 deletions deps/uv/src/win/internal.h
Expand Up @@ -337,6 +337,10 @@ int WSAAPI uv_wsarecvfrom_workaround(SOCKET socket, WSABUF* buffers,
/* Whether ipv6 is supported */
extern int uv_allow_ipv6;

/* Whether there are any non-IFS LSPs stacked on TCP */
extern int uv_tcp_non_ifs_lsp_ipv4;
extern int uv_tcp_non_ifs_lsp_ipv6;

/* Ip address used to bind to any port at any interface */
extern struct sockaddr_in uv_addr_ip4_any_;
extern struct sockaddr_in6 uv_addr_ip6_any_;
Expand Down
10 changes: 9 additions & 1 deletion deps/uv/src/win/tcp.c
Expand Up @@ -85,6 +85,7 @@ static int uv__tcp_keepalive(uv_tcp_t* handle, SOCKET socket, int enable, unsign
static int uv_tcp_set_socket(uv_loop_t* loop, uv_tcp_t* handle,
SOCKET socket, int imported) {
DWORD yes = 1;
int non_ifs_lsp;

assert(handle->socket == INVALID_SOCKET);

Expand Down Expand Up @@ -114,7 +115,10 @@ static int uv_tcp_set_socket(uv_loop_t* loop, uv_tcp_t* handle,
}
}

if (pSetFileCompletionNotificationModes) {
non_ifs_lsp = (handle->flags & UV_HANDLE_IPV6) ? uv_tcp_non_ifs_lsp_ipv6 :
uv_tcp_non_ifs_lsp_ipv4;

if (pSetFileCompletionNotificationModes && !non_ifs_lsp) {
if (pSetFileCompletionNotificationModes((HANDLE) socket,
FILE_SKIP_SET_EVENT_ON_HANDLE |
FILE_SKIP_COMPLETION_PORT_ON_SUCCESS)) {
Expand Down Expand Up @@ -1039,6 +1043,10 @@ int uv_tcp_import(uv_tcp_t* tcp, WSAPROTOCOL_INFOW* socket_protocol_info) {
tcp->flags |= UV_HANDLE_BOUND;
tcp->flags |= UV_HANDLE_SHARED_TCP_SERVER;

if (socket_protocol_info->iAddressFamily == AF_INET6) {
tcp->flags |= UV_HANDLE_IPV6;
}

return uv_tcp_set_socket(tcp->loop, tcp, socket, 1);
}

Expand Down
53 changes: 48 additions & 5 deletions deps/uv/src/win/winsock.c
Expand Up @@ -28,6 +28,10 @@
/* Whether ipv6 is supported */
int uv_allow_ipv6;

/* Whether there are any non-IFS LSPs stacked on TCP */
int uv_tcp_non_ifs_lsp_ipv4;
int uv_tcp_non_ifs_lsp_ipv6;

/* Ip address used to bind to any port at any interface */
struct sockaddr_in uv_addr_ip4_any_;
struct sockaddr_in6 uv_addr_ip6_any_;
Expand Down Expand Up @@ -80,7 +84,9 @@ void uv_winsock_init() {

WSADATA wsa_data;
int errorno;
SOCKET dummy6;
SOCKET dummy;
WSAPROTOCOL_INFOW protocol_info;
int opt_len;

/* Initialize winsock */
errorno = WSAStartup(MAKEWORD(2, 2), &wsa_data);
Expand All @@ -92,11 +98,48 @@ void uv_winsock_init() {
uv_addr_ip4_any_ = uv_ip4_addr("0.0.0.0", 0);
uv_addr_ip6_any_ = uv_ip6_addr("::", 0);

/* Detect IPV6 support */
dummy6 = socket(AF_INET6, SOCK_STREAM, IPPROTO_IP);
if (dummy6 != INVALID_SOCKET) {
/* Detect non-IFS LSPs */
dummy = socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
if (dummy == INVALID_SOCKET) {
uv_fatal_error(WSAGetLastError(), "socket");
}

opt_len = (int) sizeof protocol_info;
if (!getsockopt(dummy,
SOL_SOCKET,
SO_PROTOCOL_INFOW,
(char*) &protocol_info,
&opt_len) == SOCKET_ERROR) {
uv_fatal_error(WSAGetLastError(), "socket");
}

if (!(protocol_info.dwServiceFlags1 & XP1_IFS_HANDLES)) {
uv_tcp_non_ifs_lsp_ipv4 = 1;
}

if (closesocket(dummy) == SOCKET_ERROR) {
uv_fatal_error(WSAGetLastError(), "closesocket");
}

/* Detect IPV6 support and non-IFS LSPs */
dummy = socket(AF_INET6, SOCK_STREAM, IPPROTO_IP);
if (dummy != INVALID_SOCKET) {
uv_allow_ipv6 = TRUE;
if (closesocket(dummy6) == SOCKET_ERROR) {

opt_len = (int) sizeof protocol_info;
if (!getsockopt(dummy,
SOL_SOCKET,
SO_PROTOCOL_INFOW,
(char*) &protocol_info,
&opt_len) == SOCKET_ERROR) {
uv_fatal_error(WSAGetLastError(), "socket");
}

if (!(protocol_info.dwServiceFlags1 & XP1_IFS_HANDLES)) {
uv_tcp_non_ifs_lsp_ipv6 = 1;
}

if (closesocket(dummy) == SOCKET_ERROR) {
uv_fatal_error(WSAGetLastError(), "closesocket");
}
}
Expand Down

0 comments on commit 35c1f68

Please sign in to comment.