win: keep a reference to AFD_POLL_INFO in cancel poll
This commit is contained in:
parent
9da5fd443e
commit
cd894521dd
@ -474,7 +474,10 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
|
|||||||
/* Used in fast mode */ \
|
/* Used in fast mode */ \
|
||||||
SOCKET peer_socket; \
|
SOCKET peer_socket; \
|
||||||
AFD_POLL_INFO afd_poll_info_1; \
|
AFD_POLL_INFO afd_poll_info_1; \
|
||||||
AFD_POLL_INFO afd_poll_info_2; \
|
union { \
|
||||||
|
AFD_POLL_INFO* afd_poll_info_ptr; \
|
||||||
|
AFD_POLL_INFO afd_poll_info; \
|
||||||
|
} afd_poll_info_2; \
|
||||||
/* Used in fast and slow mode. */ \
|
/* Used in fast and slow mode. */ \
|
||||||
uv_req_t poll_req_1; \
|
uv_req_t poll_req_1; \
|
||||||
uv_req_t poll_req_2; \
|
uv_req_t poll_req_2; \
|
||||||
|
|||||||
@ -79,7 +79,7 @@ static void uv__fast_poll_submit_poll_req(uv_loop_t* loop, uv_poll_t* handle) {
|
|||||||
handle->mask_events_2 = handle->events;
|
handle->mask_events_2 = handle->events;
|
||||||
} else if (handle->submitted_events_2 == 0) {
|
} else if (handle->submitted_events_2 == 0) {
|
||||||
req = &handle->poll_req_2;
|
req = &handle->poll_req_2;
|
||||||
afd_poll_info = &handle->afd_poll_info_2;
|
afd_poll_info = &handle->afd_poll_info_2.afd_poll_info_ptr[0];
|
||||||
handle->submitted_events_2 = handle->events;
|
handle->submitted_events_2 = handle->events;
|
||||||
handle->mask_events_1 = handle->events;
|
handle->mask_events_1 = handle->events;
|
||||||
handle->mask_events_2 = 0;
|
handle->mask_events_2 = 0;
|
||||||
@ -118,18 +118,19 @@ static void uv__fast_poll_submit_poll_req(uv_loop_t* loop, uv_poll_t* handle) {
|
|||||||
|
|
||||||
|
|
||||||
static int uv__fast_poll_cancel_poll_req(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;
|
AFD_POLL_INFO* afd_poll_info;
|
||||||
DWORD result;
|
DWORD result;
|
||||||
|
|
||||||
afd_poll_info.Exclusive = TRUE;
|
afd_poll_info = &handle->afd_poll_info_2.afd_poll_info_ptr[1];
|
||||||
afd_poll_info.NumberOfHandles = 1;
|
afd_poll_info->Exclusive = TRUE;
|
||||||
afd_poll_info.Timeout.QuadPart = INT64_MAX;
|
afd_poll_info->NumberOfHandles = 1;
|
||||||
afd_poll_info.Handles[0].Handle = (HANDLE) handle->socket;
|
afd_poll_info->Timeout.QuadPart = INT64_MAX;
|
||||||
afd_poll_info.Handles[0].Status = 0;
|
afd_poll_info->Handles[0].Handle = (HANDLE) handle->socket;
|
||||||
afd_poll_info.Handles[0].Events = AFD_POLL_ALL;
|
afd_poll_info->Handles[0].Status = 0;
|
||||||
|
afd_poll_info->Handles[0].Events = AFD_POLL_ALL;
|
||||||
|
|
||||||
result = uv_msafd_poll(handle->socket,
|
result = uv_msafd_poll(handle->socket,
|
||||||
&afd_poll_info,
|
afd_poll_info,
|
||||||
uv__get_overlapped_dummy());
|
uv__get_overlapped_dummy());
|
||||||
|
|
||||||
if (result == SOCKET_ERROR) {
|
if (result == SOCKET_ERROR) {
|
||||||
@ -154,7 +155,7 @@ static void uv__fast_poll_process_poll_req(uv_loop_t* loop, uv_poll_t* handle,
|
|||||||
handle->submitted_events_1 = 0;
|
handle->submitted_events_1 = 0;
|
||||||
mask_events = handle->mask_events_1;
|
mask_events = handle->mask_events_1;
|
||||||
} else if (req == &handle->poll_req_2) {
|
} else if (req == &handle->poll_req_2) {
|
||||||
afd_poll_info = &handle->afd_poll_info_2;
|
afd_poll_info = &handle->afd_poll_info_2.afd_poll_info_ptr[0];
|
||||||
handle->submitted_events_2 = 0;
|
handle->submitted_events_2 = 0;
|
||||||
mask_events = handle->mask_events_2;
|
mask_events = handle->mask_events_2;
|
||||||
} else {
|
} else {
|
||||||
@ -551,6 +552,12 @@ int uv_poll_init_socket(uv_loop_t* loop, uv_poll_t* handle,
|
|||||||
handle->poll_req_2.type = UV_POLL_REQ;
|
handle->poll_req_2.type = UV_POLL_REQ;
|
||||||
handle->poll_req_2.data = handle;
|
handle->poll_req_2.data = handle;
|
||||||
|
|
||||||
|
handle->afd_poll_info_2.afd_poll_info_ptr = malloc(sizeof(*handle->afd_poll_info_2.afd_poll_info_ptr) * 2);
|
||||||
|
if (handle->afd_poll_info_2.afd_poll_info_ptr == NULL) {
|
||||||
|
uv__set_artificial_error(loop, UV_ENOMEM);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -604,5 +611,9 @@ void uv_poll_endgame(uv_loop_t* loop, uv_poll_t* handle) {
|
|||||||
assert(handle->submitted_events_1 == 0);
|
assert(handle->submitted_events_1 == 0);
|
||||||
assert(handle->submitted_events_2 == 0);
|
assert(handle->submitted_events_2 == 0);
|
||||||
|
|
||||||
|
if (handle->afd_poll_info_2.afd_poll_info_ptr) {
|
||||||
|
free(handle->afd_poll_info_2.afd_poll_info_ptr);
|
||||||
|
handle->afd_poll_info_2.afd_poll_info_ptr = NULL;
|
||||||
|
}
|
||||||
uv__handle_close(handle);
|
uv__handle_close(handle);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user