From 23e4c95c1c777ed0a42b5130ac35eb13ac0333ef Mon Sep 17 00:00:00 2001 From: Arseny Smirnov Date: Sat, 22 Sep 2018 17:13:49 +0300 Subject: [PATCH] Fix EventFdLinux GitOrigin-RevId: 15b9fe88f5df8489c837d75fe3705a01298e902a --- tdutils/td/utils/port/detail/EventFdLinux.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tdutils/td/utils/port/detail/EventFdLinux.cpp b/tdutils/td/utils/port/detail/EventFdLinux.cpp index e34b78bbb..9fe37eec2 100644 --- a/tdutils/td/utils/port/detail/EventFdLinux.cpp +++ b/tdutils/td/utils/port/detail/EventFdLinux.cpp @@ -81,6 +81,12 @@ void EventFdLinux::release() { } void EventFdLinux::acquire() { + impl_->info.get_flags(); + SCOPE_EXIT { + // Clear flags without EAGAIN and EWOULDBLOCK + // Looks like it is safe thing to do with eventfd + get_poll_info().clear_flags(PollFlags::Read()); + }; uint64 res; auto slice = MutableSlice(reinterpret_cast(&res), sizeof(res)); auto native_fd = impl_->info.native_fd().fd(); @@ -97,7 +103,6 @@ void EventFdLinux::acquire() { || read_errno == EWOULDBLOCK #endif ) { - get_poll_info().clear_flags(PollFlags::Read()); return 0; } return Status::PosixError(read_errno, PSLICE() << "Read from fd " << native_fd << " has failed");