Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Igor's comments

  • Loading branch information...
commit ea9ee39287342ec94f00bce8ec6ece03fc632686 1 parent 36903d3
@piscisaureus piscisaureus authored
View
25 include/uv-private/uv-win.h
@@ -104,6 +104,27 @@
DWORD dwFlags);
#endif
+typedef int (WSAAPI* LPFN_WSARECV)
+ (SOCKET socket,
+ LPWSABUF buffers,
+ DWORD buffer_count,
+ LPDWORD bytes,
+ LPDWORD flags,
+ LPWSAOVERLAPPED overlapped,
+ LPWSAOVERLAPPED_COMPLETION_ROUTINE
+ completion_routine);
+
+typedef int (WSAAPI* LPFN_WSARECVFROM)
+ (SOCKET socket,
+ LPWSABUF buffers,
+ DWORD buffer_count,
+ LPDWORD bytes,
+ LPDWORD flags,
+ struct sockaddr* addr,
+ LPINT addr_len,
+ LPWSAOVERLAPPED overlapped,
+ LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine);
+
/**
* It should be possible to cast uv_buf_t[] to WSABUF[]
@@ -236,7 +257,9 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
struct sockaddr_storage recv_from; \
int recv_from_len; \
uv_udp_recv_cb recv_cb; \
- uv_alloc_cb alloc_cb;
+ uv_alloc_cb alloc_cb; \
+ LPFN_WSARECV func_wsarecv; \
+ LPFN_WSARECVFROM func_wsarecvfrom;
#define uv_pipe_server_fields \
uv_pipe_accept_t accept_reqs[4]; \
View
2  include/uv.h
@@ -1061,7 +1061,7 @@ int uv_fs_lstat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb);
int uv_fs_link(uv_loop_t* loop, uv_fs_t* req, const char* path,
const char* new_path, uv_fs_cb cb);
-/*
+/*
* This flag can be used with uv_fs_symlink on Windows
* to specify whether path argument points to a directory.
*/
View
53 src/win/udp.c
@@ -109,6 +109,8 @@ static int uv_udp_set_socket(uv_loop_t* loop, uv_udp_t* handle,
FILE_SKIP_SET_EVENT_ON_HANDLE |
FILE_SKIP_COMPLETION_PORT_ON_SUCCESS)) {
handle->flags |= UV_HANDLE_SYNC_BYPASS_IOCP;
+ handle->func_wsarecv = uv_wsarecv_workaround;
+ handle->func_wsarecvfrom = uv_wsarecvfrom_workaround;
} else if (GetLastError() != ERROR_INVALID_FUNCTION) {
uv__set_sys_error(loop, GetLastError());
return -1;
@@ -128,6 +130,8 @@ int uv_udp_init(uv_loop_t* loop, uv_udp_t* handle) {
handle->reqs_pending = 0;
handle->loop = loop;
handle->flags = 0;
+ handle->func_wsarecv = WSARecv;
+ handle->func_wsarecvfrom = WSARecvFrom;
uv_req_init(loop, (uv_req_t*) &(handle->recv_req));
handle->recv_req.type = UV_UDP_RECV;
@@ -254,11 +258,6 @@ static void uv_udp_queue_recv(uv_loop_t* loop, uv_udp_t* handle) {
uv_buf_t buf;
DWORD bytes, flags;
int result;
- int (WSAAPI *recvfrom)(SOCKET, WSABUF*, DWORD, DWORD*, DWORD*,
- struct sockaddr*, int*, WSAOVERLAPPED*,
- LPWSAOVERLAPPED_COMPLETION_ROUTINE);
- int (WSAAPI *recv)(SOCKET, WSABUF*, DWORD, DWORD*, DWORD*,
- WSAOVERLAPPED*, LPWSAOVERLAPPED_COMPLETION_ROUTINE);
assert(handle->flags & UV_HANDLE_READING);
assert(!(handle->flags & UV_HANDLE_READ_PENDING));
@@ -281,21 +280,15 @@ static void uv_udp_queue_recv(uv_loop_t* loop, uv_udp_t* handle) {
handle->recv_from_len = sizeof handle->recv_from;
flags = 0;
- if (handle->flags & UV_HANDLE_SYNC_BYPASS_IOCP) {
- recvfrom = uv_wsarecvfrom_workaround;
- } else {
- recvfrom = WSARecvFrom;
- }
-
- result = recvfrom(handle->socket,
- (WSABUF*) &buf,
- 1,
- &bytes,
- &flags,
- (struct sockaddr*) &handle->recv_from,
- &handle->recv_from_len,
- &req->overlapped,
- NULL);
+ result = handle->func_wsarecvfrom(handle->socket,
+ (WSABUF*) &buf,
+ 1,
+ &bytes,
+ &flags,
+ (struct sockaddr*) &handle->recv_from,
+ &handle->recv_from_len,
+ &req->overlapped,
+ NULL);
if (UV_SUCCEEDED_WITHOUT_IOCP(result == 0)) {
/* Process the req without IOCP. */
@@ -321,19 +314,13 @@ static void uv_udp_queue_recv(uv_loop_t* loop, uv_udp_t* handle) {
buf.len = 0;
flags = MSG_PEEK;
- if (handle->flags & UV_HANDLE_SYNC_BYPASS_IOCP) {
- recv = uv_wsarecv_workaround;
- } else {
- recv = WSARecv;
- }
-
- result = recv(handle->socket,
- (WSABUF*) &buf,
- 1,
- &bytes,
- &flags,
- &req->overlapped,
- NULL);
+ result = handle->func_wsarecv(handle->socket,
+ (WSABUF*) &buf,
+ 1,
+ &bytes,
+ &flags,
+ &req->overlapped,
+ NULL);
if (UV_SUCCEEDED_WITHOUT_IOCP(result == 0)) {
/* Process the req without IOCP. */
View
2  src/win/winapi.c
@@ -62,7 +62,7 @@ void uv_winapi_init() {
ntdll_module,
"NtDeviceIoControlFile");
if (pNtDeviceIoControlFile == NULL) {
- uv_fatal_error(GetLastError(), "NtDeviceIoControlFile");
+ uv_fatal_error(GetLastError(), "GetProcAddress");
}
pNtSetInformationFile = (sNtSetInformationFile) GetProcAddress(
View
1  src/win/winapi.h
@@ -4343,7 +4343,6 @@ typedef BOOLEAN (WINAPI* sCreateSymbolicLinkW)
/* Ntapi function pointers */
extern sRtlNtStatusToDosError pRtlNtStatusToDosError;
extern sNtDeviceIoControlFile pNtDeviceIoControlFile;
-extern sNtDeviceIoControlFile pNtDeviceIoControlFile;
extern sNtQueryInformationFile pNtQueryInformationFile;
extern sNtSetInformationFile pNtSetInformationFile;
View
2  src/win/winsock.h
@@ -84,8 +84,6 @@ typedef struct _AFD_RECV_INFO {
ULONG BufferCount;
ULONG AfdFlags;
ULONG TdiFlags;
- struct sockaddr* Address;
- int* AddressLength;
} AFD_RECV_INFO, *PAFD_RECV_INFO;
Please sign in to comment.
Something went wrong with that request. Please try again.