diff --git a/tdutils/td/utils/port/detail/EventFdWindows.cpp b/tdutils/td/utils/port/detail/EventFdWindows.cpp index 7b55b338f..0542739d2 100644 --- a/tdutils/td/utils/port/detail/EventFdWindows.cpp +++ b/tdutils/td/utils/port/detail/EventFdWindows.cpp @@ -16,7 +16,12 @@ namespace td { namespace detail { void EventFdWindows::init() { - event_ = NativeFd(CreateEventW(nullptr, true, false, nullptr)); + auto handle = CreateEventW(nullptr, true, false, nullptr); + if (handle == nullptr) { + auto error = OS_ERROR("CreateEventW failed"); + LOG(FATAL) << error; + } + event_ = NativeFd(handle); } bool EventFdWindows::empty() { @@ -36,16 +41,25 @@ PollableFdInfo &EventFdWindows::get_poll_info() { } void EventFdWindows::release() { - SetEvent(event_.fd()); + if (SetEvent(event_.fd()) == 0) { + auto error = OS_ERROR("SetEvent failed"); + LOG(FATAL) << error; + } } void EventFdWindows::acquire() { - ResetEvent(event_.fd()); + if (ResetEvent(event_.fd()) == 0) { + auto error = OS_ERROR("ResetEvent failed"); + LOG(FATAL) << error; + } } void EventFdWindows::wait(int timeout_ms) { WaitForSingleObject(event_.fd(), timeout_ms); - ResetEvent(event_.fd()); + if (ResetEvent(event_.fd()) == 0) { + auto error = OS_ERROR("ResetEvent failed"); + LOG(FATAL) << error; + } } } // namespace detail diff --git a/tdutils/td/utils/port/detail/Iocp.cpp b/tdutils/td/utils/port/detail/Iocp.cpp index f651d54ea..9e3f2b5bc 100644 --- a/tdutils/td/utils/port/detail/Iocp.cpp +++ b/tdutils/td/utils/port/detail/Iocp.cpp @@ -69,7 +69,7 @@ void Iocp::subscribe(const NativeFd &native_fd, Callback *callback) { CHECK(iocp_handle_); auto iocp_handle = CreateIoCompletionPort(native_fd.fd(), iocp_handle_.fd(), reinterpret_cast(callback), 0); - if (iocp_handle == INVALID_HANDLE_VALUE) { + if (iocp_handle == nullptr) { auto error = OS_ERROR("CreateIoCompletionPort"); LOG(FATAL) << error; } @@ -77,8 +77,11 @@ void Iocp::subscribe(const NativeFd &native_fd, Callback *callback) { } void Iocp::post(size_t size, Callback *callback, WSAOVERLAPPED *overlapped) { - PostQueuedCompletionStatus(iocp_handle_.fd(), DWORD(size), reinterpret_cast(callback), - reinterpret_cast(overlapped)); + if (PostQueuedCompletionStatus(iocp_handle_.fd(), DWORD(size), reinterpret_cast(callback), + reinterpret_cast(overlapped)) == 0) { + auto error = OS_ERROR("IOCP post failed"); + LOG(FATAL) << error; + } } } // namespace detail