sock: avoid a syscall when cancelling already-completed poll operation

This commit is contained in:
Bert Belder 2018-11-16 23:46:08 -08:00
parent 5c32cea921
commit bf5e17e5c5
No known key found for this signature in database
GPG Key ID: 7A77887B2E2ED461

View File

@ -53,7 +53,8 @@ static int sock__cancel_poll(sock_state_t* sock_state) {
/* CancelIoEx() may fail with ERROR_NOT_FOUND if the overlapped operation has /* CancelIoEx() may fail with ERROR_NOT_FOUND if the overlapped operation has
* already completed. This is not a problem and we proceed normally. */ * already completed. This is not a problem and we proceed normally. */
if (!CancelIoEx(afd_helper_handle, &sock_state->overlapped) && if (!HasOverlappedIoCompleted(&sock_state->overlapped) &&
!CancelIoEx(afd_helper_handle, &sock_state->overlapped) &&
GetLastError() != ERROR_NOT_FOUND) GetLastError() != ERROR_NOT_FOUND)
return_map_error(-1); return_map_error(-1);