Index: runtime/bin/eventhandler_android.cc |
diff --git a/runtime/bin/eventhandler_android.cc b/runtime/bin/eventhandler_android.cc |
index 6fdabfb9fae87e25c972ab2703f45fb45e65f890..5daeb78df0f1d378dc2650df8889ef14a1911f9f 100644 |
--- a/runtime/bin/eventhandler_android.cc |
+++ b/runtime/bin/eventhandler_android.cc |
@@ -9,13 +9,13 @@ |
#include "bin/eventhandler_android.h" |
#include <errno.h> // NOLINT |
+#include <fcntl.h> // NOLINT |
#include <pthread.h> // NOLINT |
#include <stdio.h> // NOLINT |
#include <string.h> // NOLINT |
#include <sys/epoll.h> // NOLINT |
#include <sys/stat.h> // NOLINT |
#include <unistd.h> // NOLINT |
-#include <fcntl.h> // NOLINT |
#include "bin/dartutils.h" |
#include "bin/fdutils.h" |
@@ -27,17 +27,14 @@ |
#include "platform/hashmap.h" |
#include "platform/utils.h" |
- |
// Android doesn't define EPOLLRDHUP. |
#if !defined(EPOLLRDHUP) |
#define EPOLLRDHUP 0x2000 |
#endif // !defined(EPOLLRDHUP) |
- |
namespace dart { |
namespace bin { |
- |
intptr_t DescriptorInfo::GetPollEvents() { |
// Do not ask for EPOLLERR and EPOLLHUP explicitly as they are |
// triggered anyway. |
@@ -129,11 +126,11 @@ EventHandlerImplementation::~EventHandlerImplementation() { |
void EventHandlerImplementation::UpdateEpollInstance(intptr_t old_mask, |
DescriptorInfo *di) { |
intptr_t new_mask = di->Mask(); |
- if (old_mask != 0 && new_mask == 0) { |
+ if ((old_mask != 0) && (new_mask == 0)) { |
RemoveFromEpollInstance(epoll_fd_, di); |
- } else if (old_mask == 0 && new_mask != 0) { |
+ } else if ((old_mask == 0) && (new_mask != 0)) { |
AddToEpollInstance(epoll_fd_, di); |
- } else if (old_mask != 0 && new_mask != 0 && old_mask != new_mask) { |
+ } else if ((old_mask != 0) && (new_mask != 0) && (old_mask != new_mask)) { |
ASSERT(!di->IsListeningSocket()); |
RemoveFromEpollInstance(epoll_fd_, di); |
AddToEpollInstance(epoll_fd_, di); |
@@ -264,15 +261,28 @@ void EventHandlerImplementation::HandleInterruptFd() { |
} |
} |
+ |
#ifdef DEBUG_POLL |
static void PrintEventMask(intptr_t fd, intptr_t events) { |
Log::Print("%d ", fd); |
- if ((events & EPOLLIN) != 0) Log::Print("EPOLLIN "); |
- if ((events & EPOLLPRI) != 0) Log::Print("EPOLLPRI "); |
- if ((events & EPOLLOUT) != 0) Log::Print("EPOLLOUT "); |
- if ((events & EPOLLERR) != 0) Log::Print("EPOLLERR "); |
- if ((events & EPOLLHUP) != 0) Log::Print("EPOLLHUP "); |
- if ((events & EPOLLRDHUP) != 0) Log::Print("EPOLLRDHUP "); |
+ if ((events & EPOLLIN) != 0) { |
+ Log::Print("EPOLLIN "); |
+ } |
+ if ((events & EPOLLPRI) != 0) { |
+ Log::Print("EPOLLPRI "); |
+ } |
+ if ((events & EPOLLOUT) != 0) { |
+ Log::Print("EPOLLOUT "); |
+ } |
+ if ((events & EPOLLERR) != 0) { |
+ Log::Print("EPOLLERR "); |
+ } |
+ if ((events & EPOLLHUP) != 0) { |
+ Log::Print("EPOLLHUP "); |
+ } |
+ if ((events & EPOLLRDHUP) != 0) { |
+ Log::Print("EPOLLRDHUP "); |
+ } |
int all_events = EPOLLIN | EPOLLPRI | EPOLLOUT | |
EPOLLERR | EPOLLHUP | EPOLLRDHUP; |
if ((events & ~all_events) != 0) { |
@@ -284,19 +294,26 @@ static void PrintEventMask(intptr_t fd, intptr_t events) { |
} |
#endif |
+ |
intptr_t EventHandlerImplementation::GetPollEvents(intptr_t events, |
DescriptorInfo* di) { |
#ifdef DEBUG_POLL |
PrintEventMask(di->fd(), events); |
#endif |
- if (events & EPOLLERR) { |
+ if ((events & EPOLLERR) != 0) { |
// Return error only if EPOLLIN is present. |
- return (events & EPOLLIN) ? (1 << kErrorEvent) : 0; |
+ return ((events & EPOLLIN) != 0) ? (1 << kErrorEvent) : 0; |
} |
intptr_t event_mask = 0; |
- if (events & EPOLLIN) event_mask |= (1 << kInEvent); |
- if (events & EPOLLOUT) event_mask |= (1 << kOutEvent); |
- if (events & (EPOLLHUP | EPOLLRDHUP)) event_mask |= (1 << kCloseEvent); |
+ if ((events & EPOLLIN) != 0) { |
+ event_mask |= (1 << kInEvent); |
+ } |
+ if ((events & EPOLLOUT) != 0) { |
+ event_mask |= (1 << kOutEvent); |
+ } |
+ if ((events & (EPOLLHUP | EPOLLRDHUP)) != 0) { |
+ event_mask |= (1 << kCloseEvent); |
+ } |
return event_mask; |
} |
@@ -360,8 +377,10 @@ void EventHandlerImplementation::Poll(uword args) { |
while (!handler_impl->shutdown_) { |
int64_t millis = handler_impl->GetTimeout(); |
- ASSERT(millis == kInfinityTimeout || millis >= 0); |
- if (millis > kMaxInt32) millis = kMaxInt32; |
+ ASSERT((millis == kInfinityTimeout) || (millis >= 0)); |
+ if (millis > kMaxInt32) { |
+ millis = kMaxInt32; |
+ } |
intptr_t result = TEMP_FAILURE_RETRY_NO_SIGNAL_BLOCKER( |
epoll_wait(handler_impl->epoll_fd_, events, kMaxEvents, millis)); |
ASSERT(EAGAIN == EWOULDBLOCK); |