Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(545)

Unified Diff: runtime/bin/eventhandler_android.cc

Issue 83963003: Removes EPOLLONESHOT from Android eventhandler. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/eventhandler_android.cc
===================================================================
--- runtime/bin/eventhandler_android.cc (revision 30595)
+++ runtime/bin/eventhandler_android.cc (working copy)
@@ -74,9 +74,6 @@
event.events = sd->GetPollEvents();
event.data.ptr = sd;
if (sd->port() != 0 && event.events != 0) {
- // Only report events once and wait for them to be re-enabled after the
- // event has been handled by the Dart code.
- event.events |= EPOLLONESHOT;
int status = 0;
if (sd->tracked_by_epoll()) {
status = TEMP_FAILURE_RETRY(epoll_ctl(epoll_fd_,
@@ -179,29 +176,32 @@
void EventHandlerImplementation::HandleInterruptFd() {
- const intptr_t MAX_MESSAGES = kInterruptMessageSize;
- InterruptMessage msg[MAX_MESSAGES];
- ssize_t bytes = TEMP_FAILURE_RETRY(
- read(interrupt_fds_[0], msg, MAX_MESSAGES * kInterruptMessageSize));
- for (ssize_t i = 0; i < bytes / kInterruptMessageSize; i++) {
- if (msg[i].id == kTimerId) {
- timeout_queue_.UpdateTimeout(msg[i].dart_port, msg[i].data);
- } else if (msg[i].id == kShutdownId) {
+ InterruptMessage msg;
Ivan Posva 2013/11/22 23:38:25 As discussed I don't think these changes had anyth
+ intptr_t available = FDUtils::AvailableBytes(interrupt_fds_[0]);
+ for (int i = 0;
+ i + kInterruptMessageSize <= available;
+ i += kInterruptMessageSize) {
+ VOID_TEMP_FAILURE_RETRY(read(interrupt_fds_[0],
+ reinterpret_cast<char*>(&msg),
+ kInterruptMessageSize));
+ if (msg.id == kTimerId) {
+ timeout_queue_.UpdateTimeout(msg.dart_port, msg.data);
+ } else if (msg.id == kShutdownId) {
shutdown_ = true;
} else {
- SocketData* sd = GetSocketData(msg[i].id);
- if ((msg[i].data & (1 << kShutdownReadCommand)) != 0) {
- ASSERT(msg[i].data == (1 << kShutdownReadCommand));
+ SocketData* sd = GetSocketData(msg.id);
+ if ((msg.data & (1 << kShutdownReadCommand)) != 0) {
+ ASSERT(msg.data == (1 << kShutdownReadCommand));
// Close the socket for reading.
sd->ShutdownRead();
UpdateEpollInstance(epoll_fd_, sd);
- } else if ((msg[i].data & (1 << kShutdownWriteCommand)) != 0) {
- ASSERT(msg[i].data == (1 << kShutdownWriteCommand));
+ } else if ((msg.data & (1 << kShutdownWriteCommand)) != 0) {
+ ASSERT(msg.data == (1 << kShutdownWriteCommand));
// Close the socket for writing.
sd->ShutdownWrite();
UpdateEpollInstance(epoll_fd_, sd);
- } else if ((msg[i].data & (1 << kCloseCommand)) != 0) {
- ASSERT(msg[i].data == (1 << kCloseCommand));
+ } else if ((msg.data & (1 << kCloseCommand)) != 0) {
+ ASSERT(msg.data == (1 << kCloseCommand));
// Close the socket and free system resources and move on to
// next message.
RemoveFromEpollInstance(epoll_fd_, sd);
@@ -217,10 +217,10 @@
}
socket_map_.Remove(GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd));
delete sd;
- DartUtils::PostInt32(msg[i].dart_port, 1 << kDestroyedEvent);
+ DartUtils::PostInt32(msg.dart_port, 1 << kDestroyedEvent);
} else {
// Setup events to wait for.
- sd->SetPortAndMask(msg[i].dart_port, msg[i].data);
+ sd->SetPortAndMask(msg.dart_port, msg.data);
UpdateEpollInstance(epoll_fd_, sd);
}
}
@@ -341,10 +341,11 @@
} else {
SocketData* sd = reinterpret_cast<SocketData*>(events[i].data.ptr);
intptr_t event_mask = GetPollEvents(events[i].events, sd);
- if (event_mask == 0) {
- // Event not handled, re-add to epoll.
- UpdateEpollInstance(epoll_fd_, sd);
- } else {
+ if (event_mask != 0) {
+ // Unregister events for the file descriptor. Events will be
+ // registered again when the current event has been handled in
+ // Dart code.
+ RemoveFromEpollInstance(epoll_fd_, sd);
Dart_Port port = sd->port();
ASSERT(port != 0);
DartUtils::PostInt32(port, event_mask);
@@ -400,9 +401,8 @@
if (errno != EWOULDBLOCK) {
perror("Poll failed");
}
- } else if (result == 0) {
+ } else {
handler->HandleTimeout();
- } else {
handler->HandleEvents(events, result);
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698