Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
windows: fix bugs in uv__fast_poll_cancel_poll_req
Browse files Browse the repository at this point in the history
  • Loading branch information
piscisaureus committed Jun 1, 2012
1 parent 04a7e5c commit 528123a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/win/poll.c
Expand Up @@ -94,7 +94,7 @@ static void uv__fast_poll_submit_poll_req(uv_loop_t* loop, uv_poll_t* handle) {
}


static int uv__fast_poll_cancel_poll_reqs(uv_loop_t* loop, uv_poll_t* handle) {
static int uv__fast_poll_cancel_poll_req(uv_loop_t* loop, uv_poll_t* handle) {
AFD_POLL_INFO afd_poll_info;
DWORD result;
HANDLE event;
Expand All @@ -106,15 +106,15 @@ static int uv__fast_poll_cancel_poll_reqs(uv_loop_t* loop, uv_poll_t* handle) {
return -1;
}

afd_poll_info.Exclusive = TRUE;
afd_poll_info.Exclusive = FALSE;
afd_poll_info.NumberOfHandles = 1;
afd_poll_info.Timeout.QuadPart = INT64_MAX;
afd_poll_info.Timeout.QuadPart = 0;
afd_poll_info.Handles[0].Handle = (HANDLE) handle->socket;
afd_poll_info.Handles[0].Status = 0;
afd_poll_info.Handles[0].Events = AFD_POLL_ALL;

memset(&overlapped, 0, sizeof overlapped);
overlapped.hEvent = (HANDLE) ((uintptr_t) event & 1);
overlapped.hEvent = (HANDLE) ((uintptr_t) event | 1);

result = uv_msafd_poll(handle->socket,
&afd_poll_info,
Expand All @@ -129,6 +129,10 @@ static int uv__fast_poll_cancel_poll_reqs(uv_loop_t* loop, uv_poll_t* handle) {
}
}

if (WaitForSingleObject(event, INFINITE) != WAIT_OBJECT_0) {
uv_fatal_error(GetLastError(), "WaitForSingleObject");
}

CloseHandle(event);
return 0;
}
Expand Down Expand Up @@ -234,7 +238,7 @@ static void uv__fast_poll_close(uv_loop_t* loop, uv_poll_t* handle) {
pCancelIoEx((HANDLE) handle->socket, &handle->poll_req_2.overlapped);
} else if (handle->submitted_events_1 | handle->submitted_events_2) {
/* Execute another unique poll to force the others to return. */
uv__fast_poll_cancel_poll_reqs(loop, handle);
uv__fast_poll_cancel_poll_req(loop, handle);
}
}
}
Expand Down

0 comments on commit 528123a

Please sign in to comment.