Fix checking of return values.
GitOrigin-RevId: 81accbd062db24d031a3054ba5cc86ace38774ad
This commit is contained in:
parent
496d7b3e52
commit
30ceb55fb4
@ -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
|
||||
|
@ -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<ULONG_PTR>(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<ULONG_PTR>(callback),
|
||||
reinterpret_cast<OVERLAPPED *>(overlapped));
|
||||
if (PostQueuedCompletionStatus(iocp_handle_.fd(), DWORD(size), reinterpret_cast<ULONG_PTR>(callback),
|
||||
reinterpret_cast<OVERLAPPED *>(overlapped)) == 0) {
|
||||
auto error = OS_ERROR("IOCP post failed");
|
||||
LOG(FATAL) << error;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
Reference in New Issue
Block a user