This repository has been archived by the owner on May 4, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
,,
- Loading branch information
1 parent
ffe2ef0
commit c93cccb
Showing
46 changed files
with
20,854 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
From 7a305a2a517b2e3aa7dcb572a1e8d699f06b6faa Mon Sep 17 00:00:00 2001 | ||
From: Bert Belder <bertbelder@gmail.com> | ||
Date: Sat, 26 Jan 2013 02:46:25 +0100 | ||
Subject: [PATCH 1/7] win: sort error code mappings | ||
|
||
--- | ||
src/win/error.c | 72 ++++++++++++++++++++++++++++----------------------------- | ||
1 file changed, 36 insertions(+), 36 deletions(-) | ||
|
||
diff --git a/src/win/error.c b/src/win/error.c | ||
index ff79f9c..c72117f 100644 | ||
--- a/src/win/error.c | ||
+++ b/src/win/error.c | ||
@@ -66,31 +66,6 @@ void uv_fatal_error(const int errorno, const char* syscall) { | ||
uv_err_code uv_translate_sys_error(int sys_errno) { | ||
switch (sys_errno) { | ||
case ERROR_SUCCESS: return UV_OK; | ||
- case ERROR_BEGINNING_OF_MEDIA: return UV_EIO; | ||
- case ERROR_BUS_RESET: return UV_EIO; | ||
- case ERROR_CRC: return UV_EIO; | ||
- case ERROR_DEVICE_DOOR_OPEN: return UV_EIO; | ||
- case ERROR_DEVICE_REQUIRES_CLEANING: return UV_EIO; | ||
- case ERROR_DISK_CORRUPT: return UV_EIO; | ||
- case ERROR_EOM_OVERFLOW: return UV_EIO; | ||
- case ERROR_FILEMARK_DETECTED: return UV_EIO; | ||
- case ERROR_GEN_FAILURE: return UV_EIO; | ||
- case ERROR_INVALID_BLOCK_LENGTH: return UV_EIO; | ||
- case ERROR_IO_DEVICE: return UV_EIO; | ||
- case ERROR_NO_DATA_DETECTED: return UV_EIO; | ||
- case ERROR_NO_SIGNAL_SENT: return UV_EIO; | ||
- case ERROR_OPEN_FAILED: return UV_EIO; | ||
- case ERROR_SETMARK_DETECTED: return UV_EIO; | ||
- case ERROR_SIGNAL_REFUSED: return UV_EIO; | ||
- case ERROR_DIRECTORY: return UV_ENOENT; | ||
- case ERROR_FILE_NOT_FOUND: return UV_ENOENT; | ||
- case ERROR_INVALID_NAME: return UV_ENOENT; | ||
- case ERROR_INVALID_REPARSE_DATA: return UV_ENOENT; | ||
- case ERROR_MOD_NOT_FOUND: return UV_ENOENT; | ||
- case ERROR_PATH_NOT_FOUND: return UV_ENOENT; | ||
- case WSANO_DATA: return UV_ENOENT; | ||
- case ERROR_ACCESS_DENIED: return UV_EPERM; | ||
- case ERROR_PRIVILEGE_NOT_HELD: return UV_EPERM; | ||
case ERROR_NOACCESS: return UV_EACCES; | ||
case WSAEACCES: return UV_EACCES; | ||
case ERROR_ADDRESS_ALREADY_ASSOCIATED: return UV_EADDRINUSE; | ||
@@ -99,8 +74,14 @@ uv_err_code uv_translate_sys_error(int sys_errno) { | ||
case WSAEAFNOSUPPORT: return UV_EAFNOSUPPORT; | ||
case WSAEWOULDBLOCK: return UV_EAGAIN; | ||
case WSAEALREADY: return UV_EALREADY; | ||
+ case ERROR_INVALID_FLAGS: return UV_EBADF; | ||
+ case ERROR_INVALID_HANDLE: return UV_EBADF; | ||
case ERROR_LOCK_VIOLATION: return UV_EBUSY; | ||
+ case ERROR_PIPE_BUSY: return UV_EBUSY; | ||
case ERROR_SHARING_VIOLATION: return UV_EBUSY; | ||
+ case ERROR_OPERATION_ABORTED: return UV_ECANCELED; | ||
+ case WSAEINTR: return UV_ECANCELED; | ||
+ case ERROR_NO_UNICODE_TRANSLATION: return UV_ECHARSET; | ||
case ERROR_CONNECTION_ABORTED: return UV_ECONNABORTED; | ||
case WSAECONNABORTED: return UV_ECONNABORTED; | ||
case ERROR_CONNECTION_REFUSED: return UV_ECONNREFUSED; | ||
@@ -113,11 +94,27 @@ uv_err_code uv_translate_sys_error(int sys_errno) { | ||
case WSAEFAULT: return UV_EFAULT; | ||
case ERROR_HOST_UNREACHABLE: return UV_EHOSTUNREACH; | ||
case WSAEHOSTUNREACH: return UV_EHOSTUNREACH; | ||
- case ERROR_OPERATION_ABORTED: return UV_ECANCELED; | ||
- case WSAEINTR: return UV_ECANCELED; | ||
+ case ERROR_INSUFFICIENT_BUFFER: return UV_EINVAL; | ||
case ERROR_INVALID_DATA: return UV_EINVAL; | ||
+ case ERROR_INVALID_PARAMETER: return UV_EINVAL; | ||
case ERROR_SYMLINK_NOT_SUPPORTED: return UV_EINVAL; | ||
case WSAEINVAL: return UV_EINVAL; | ||
+ case ERROR_BEGINNING_OF_MEDIA: return UV_EIO; | ||
+ case ERROR_BUS_RESET: return UV_EIO; | ||
+ case ERROR_CRC: return UV_EIO; | ||
+ case ERROR_DEVICE_DOOR_OPEN: return UV_EIO; | ||
+ case ERROR_DEVICE_REQUIRES_CLEANING: return UV_EIO; | ||
+ case ERROR_DISK_CORRUPT: return UV_EIO; | ||
+ case ERROR_EOM_OVERFLOW: return UV_EIO; | ||
+ case ERROR_FILEMARK_DETECTED: return UV_EIO; | ||
+ case ERROR_GEN_FAILURE: return UV_EIO; | ||
+ case ERROR_INVALID_BLOCK_LENGTH: return UV_EIO; | ||
+ case ERROR_IO_DEVICE: return UV_EIO; | ||
+ case ERROR_NO_DATA_DETECTED: return UV_EIO; | ||
+ case ERROR_NO_SIGNAL_SENT: return UV_EIO; | ||
+ case ERROR_OPEN_FAILED: return UV_EIO; | ||
+ case ERROR_SETMARK_DETECTED: return UV_EIO; | ||
+ case ERROR_SIGNAL_REFUSED: return UV_EIO; | ||
case ERROR_CANT_RESOLVE_FILENAME: return UV_ELOOP; | ||
case ERROR_TOO_MANY_OPEN_FILES: return UV_EMFILE; | ||
case WSAEMFILE: return UV_EMFILE; | ||
@@ -126,6 +123,14 @@ uv_err_code uv_translate_sys_error(int sys_errno) { | ||
case ERROR_NETWORK_UNREACHABLE: return UV_ENETUNREACH; | ||
case WSAENETUNREACH: return UV_ENETUNREACH; | ||
case WSAENOBUFS: return UV_ENOBUFS; | ||
+ case ERROR_DIRECTORY: return UV_ENOENT; | ||
+ case ERROR_FILE_NOT_FOUND: return UV_ENOENT; | ||
+ case ERROR_INVALID_NAME: return UV_ENOENT; | ||
+ case ERROR_INVALID_REPARSE_DATA: return UV_ENOENT; | ||
+ case ERROR_MOD_NOT_FOUND: return UV_ENOENT; | ||
+ case ERROR_PATH_NOT_FOUND: return UV_ENOENT; | ||
+ case WSAHOST_NOT_FOUND: return UV_ENOENT; | ||
+ case WSANO_DATA: return UV_ENOENT; | ||
case ERROR_NOT_ENOUGH_MEMORY: return UV_ENOMEM; | ||
case ERROR_OUTOFMEMORY: return UV_ENOMEM; | ||
case ERROR_CANNOT_MAKE: return UV_ENOSPC; | ||
@@ -133,26 +138,21 @@ uv_err_code uv_translate_sys_error(int sys_errno) { | ||
case ERROR_EA_TABLE_FULL: return UV_ENOSPC; | ||
case ERROR_END_OF_MEDIA: return UV_ENOSPC; | ||
case ERROR_HANDLE_DISK_FULL: return UV_ENOSPC; | ||
- case ERROR_WRITE_PROTECT: return UV_EROFS; | ||
case ERROR_NOT_CONNECTED: return UV_ENOTCONN; | ||
case WSAENOTCONN: return UV_ENOTCONN; | ||
case ERROR_DIR_NOT_EMPTY: return UV_ENOTEMPTY; | ||
+ case WSAENOTSOCK: return UV_ENOTSOCK; | ||
case ERROR_NOT_SUPPORTED: return UV_ENOTSUP; | ||
- case ERROR_INSUFFICIENT_BUFFER: return UV_EINVAL; | ||
- case ERROR_INVALID_FLAGS: return UV_EBADF; | ||
- case ERROR_INVALID_HANDLE: return UV_EBADF; | ||
- case ERROR_INVALID_PARAMETER: return UV_EINVAL; | ||
- case ERROR_NO_UNICODE_TRANSLATION: return UV_ECHARSET; | ||
case ERROR_BROKEN_PIPE: return UV_EOF; | ||
+ case ERROR_ACCESS_DENIED: return UV_EPERM; | ||
+ case ERROR_PRIVILEGE_NOT_HELD: return UV_EPERM; | ||
case ERROR_BAD_PIPE: return UV_EPIPE; | ||
case ERROR_NO_DATA: return UV_EPIPE; | ||
case ERROR_PIPE_NOT_CONNECTED: return UV_EPIPE; | ||
case WSAESHUTDOWN: return UV_EPIPE; | ||
- case ERROR_PIPE_BUSY: return UV_EBUSY; | ||
+ case ERROR_WRITE_PROTECT: return UV_EROFS; | ||
case ERROR_SEM_TIMEOUT: return UV_ETIMEDOUT; | ||
case WSAETIMEDOUT: return UV_ETIMEDOUT; | ||
- case WSAHOST_NOT_FOUND: return UV_ENOENT; | ||
- case WSAENOTSOCK: return UV_ENOTSOCK; | ||
case ERROR_NOT_SAME_DEVICE: return UV_EXDEV; | ||
default: return UV_UNKNOWN; | ||
} | ||
-- | ||
1.8.0.msysgit.0 | ||
|
32 changes: 32 additions & 0 deletions
32
0001-win-tcp-don-t-enable-iocp-sync-bypass-when-iocp-emul.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
From b9e9d4951c106d03f99352274c67d6891c2b5cff Mon Sep 17 00:00:00 2001 | ||
From: Bert Belder <bertbelder@gmail.com> | ||
Date: Sat, 9 Mar 2013 20:19:28 +0100 | ||
Subject: [PATCH 1/1] win/tcp: don't enable iocp sync bypass when iocp | ||
emulation is used | ||
|
||
When iocp sync bypass is in use libuv doesn't expect the system to | ||
generate events when an i/o operation completes synchronously. However | ||
when iocp emulation is enabled an event will always be generated because | ||
SetFileCompletionNotificationModes() doesn't stop OVERLAPPED.hEvent from | ||
becoming signaled. | ||
--- | ||
src/win/tcp.c | 3 ++- | ||
1 file changed, 2 insertions(+), 1 deletion(-) | ||
|
||
diff --git a/src/win/tcp.c b/src/win/tcp.c | ||
index 7158216..c3ef653 100644 | ||
--- a/src/win/tcp.c | ||
+++ b/src/win/tcp.c | ||
@@ -113,7 +113,8 @@ static int uv_tcp_set_socket(uv_loop_t* loop, uv_tcp_t* handle, | ||
non_ifs_lsp = uv_tcp_non_ifs_lsp_ipv4; | ||
} | ||
|
||
- if (pSetFileCompletionNotificationModes && !non_ifs_lsp) { | ||
+ if (pSetFileCompletionNotificationModes && | ||
+ !(handle->flags & UV_HANDLE_EMULATE_IOCP) && !non_ifs_lsp) { | ||
if (pSetFileCompletionNotificationModes((HANDLE) socket, | ||
FILE_SKIP_SET_EVENT_ON_HANDLE | | ||
FILE_SKIP_COMPLETION_PORT_ON_SUCCESS)) { | ||
-- | ||
1.8.0.msysgit.0 | ||
|
33 changes: 33 additions & 0 deletions
33
0002-win-add-error-mappings-related-to-unsupported-protoc.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
From 391a3176217165dd26cd8c652491b350709299fb Mon Sep 17 00:00:00 2001 | ||
From: Bert Belder <bertbelder@gmail.com> | ||
Date: Sat, 26 Jan 2013 02:46:51 +0100 | ||
Subject: [PATCH 2/7] win: add error mappings related to unsupported protocols | ||
|
||
--- | ||
src/win/error.c | 3 +++ | ||
1 file changed, 3 insertions(+) | ||
|
||
diff --git a/src/win/error.c b/src/win/error.c | ||
index c72117f..40852cf 100644 | ||
--- a/src/win/error.c | ||
+++ b/src/win/error.c | ||
@@ -99,6 +99,8 @@ uv_err_code uv_translate_sys_error(int sys_errno) { | ||
case ERROR_INVALID_PARAMETER: return UV_EINVAL; | ||
case ERROR_SYMLINK_NOT_SUPPORTED: return UV_EINVAL; | ||
case WSAEINVAL: return UV_EINVAL; | ||
+ case WSAEPFNOSUPPORT: return UV_EINVAL; | ||
+ case WSAESOCKTNOSUPPORT: return UV_EINVAL; | ||
case ERROR_BEGINNING_OF_MEDIA: return UV_EIO; | ||
case ERROR_BUS_RESET: return UV_EIO; | ||
case ERROR_CRC: return UV_EIO; | ||
@@ -150,6 +152,7 @@ uv_err_code uv_translate_sys_error(int sys_errno) { | ||
case ERROR_NO_DATA: return UV_EPIPE; | ||
case ERROR_PIPE_NOT_CONNECTED: return UV_EPIPE; | ||
case WSAESHUTDOWN: return UV_EPIPE; | ||
+ case WSAEPROTONOSUPPORT: return UV_EPROTONOSUPPORT; | ||
case ERROR_WRITE_PROTECT: return UV_EROFS; | ||
case ERROR_SEM_TIMEOUT: return UV_ETIMEDOUT; | ||
case WSAETIMEDOUT: return UV_ETIMEDOUT; | ||
-- | ||
1.8.0.msysgit.0 | ||
|
111 changes: 111 additions & 0 deletions
111
0003-win-fix-uv_winsock_init-crash-when-no-IPv4-stack-pre.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
From 9d19cc838cb8854b113edc05e2e106ca98ac4dd4 Mon Sep 17 00:00:00 2001 | ||
From: Bert Belder <bertbelder@gmail.com> | ||
Date: Sat, 26 Jan 2013 03:52:32 +0100 | ||
Subject: [PATCH 3/7] win: fix uv_winsock_init crash when no IPv4 stack | ||
present | ||
|
||
uv_winsock_init() tries to create an IPv4 socket in order to detect | ||
if the system has any layered service providers (LSPs) installed. | ||
When creating this socket failed it would call uv_fatal_error and exit | ||
with the following message: | ||
|
||
socket: (10047) An address incompatible with the requested protocol was used. | ||
|
||
This patch fixes that. It also includes some minor style tweaks. | ||
--- | ||
src/win/winsock.c | 54 +++++++++++++++++++++++++++++++----------------------- | ||
1 file changed, 31 insertions(+), 23 deletions(-) | ||
|
||
diff --git a/src/win/winsock.c b/src/win/winsock.c | ||
index 2c3e49a..cbd25af 100644 | ||
--- a/src/win/winsock.c | ||
+++ b/src/win/winsock.c | ||
@@ -75,6 +75,12 @@ BOOL uv_get_connectex_function(SOCKET socket, LPFN_CONNECTEX* target) { | ||
} | ||
|
||
|
||
+static int error_means_no_support(DWORD error) { | ||
+ return error == WSAEPROTONOSUPPORT || error == WSAESOCKTNOSUPPORT || | ||
+ error == WSAEPFNOSUPPORT || error == WSAEAFNOSUPPORT; | ||
+} | ||
+ | ||
+ | ||
void uv_winsock_init() { | ||
const GUID wsaid_connectex = WSAID_CONNECTEX; | ||
const GUID wsaid_acceptex = WSAID_ACCEPTEX; | ||
@@ -100,29 +106,30 @@ void uv_winsock_init() { | ||
|
||
/* 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 (dummy != INVALID_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(), "getsockopt"); | ||
|
||
- if (!(protocol_info.dwServiceFlags1 & XP1_IFS_HANDLES)) { | ||
- uv_tcp_non_ifs_lsp_ipv4 = 1; | ||
- } | ||
+ if (!(protocol_info.dwServiceFlags1 & XP1_IFS_HANDLES)) | ||
+ uv_tcp_non_ifs_lsp_ipv4 = 1; | ||
+ | ||
+ if (closesocket(dummy) == SOCKET_ERROR) | ||
+ uv_fatal_error(WSAGetLastError(), "closesocket"); | ||
|
||
- if (closesocket(dummy) == SOCKET_ERROR) { | ||
- uv_fatal_error(WSAGetLastError(), "closesocket"); | ||
+ } else if (!error_means_no_support(WSAGetLastError())) { | ||
+ /* Any error other than "socket type not supported" is fatal. */ | ||
+ uv_fatal_error(WSAGetLastError(), "socket"); | ||
} | ||
|
||
/* Detect IPV6 support and non-IFS LSPs */ | ||
dummy = socket(AF_INET6, SOCK_STREAM, IPPROTO_IP); | ||
+ | ||
if (dummy != INVALID_SOCKET) { | ||
uv_allow_ipv6 = TRUE; | ||
|
||
@@ -131,17 +138,18 @@ void uv_winsock_init() { | ||
SOL_SOCKET, | ||
SO_PROTOCOL_INFOW, | ||
(char*) &protocol_info, | ||
- &opt_len) == SOCKET_ERROR) { | ||
- uv_fatal_error(WSAGetLastError(), "socket"); | ||
- } | ||
+ &opt_len) == SOCKET_ERROR) | ||
+ uv_fatal_error(WSAGetLastError(), "getsockopt"); | ||
|
||
- if (!(protocol_info.dwServiceFlags1 & XP1_IFS_HANDLES)) { | ||
+ if (!(protocol_info.dwServiceFlags1 & XP1_IFS_HANDLES)) | ||
uv_tcp_non_ifs_lsp_ipv6 = 1; | ||
- } | ||
|
||
- if (closesocket(dummy) == SOCKET_ERROR) { | ||
+ if (closesocket(dummy) == SOCKET_ERROR) | ||
uv_fatal_error(WSAGetLastError(), "closesocket"); | ||
- } | ||
+ | ||
+ } else if (!error_means_no_support(WSAGetLastError())) { | ||
+ /* Any error other than "socket type not supported" is fatal. */ | ||
+ uv_fatal_error(WSAGetLastError(), "socket"); | ||
} | ||
} | ||
|
||
-- | ||
1.8.0.msysgit.0 | ||
|
Oops, something went wrong.