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

Unified Diff: runtime/bin/eventhandler_linux.cc

Issue 8399039: Explicitly handle listen sockets and connection sockets differently in Linux and Mac OS eventhandler (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix Mac OS build Created 9 years, 2 months 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 | « runtime/bin/eventhandler_linux.h ('k') | runtime/bin/eventhandler_macos.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/eventhandler_linux.cc
diff --git a/runtime/bin/eventhandler_linux.cc b/runtime/bin/eventhandler_linux.cc
index a72f42a36ed6794f39ba5208ff642246e2e72e5a..0f60633aea5805c940af41b66b053e11022ed579 100644
--- a/runtime/bin/eventhandler_linux.cc
+++ b/runtime/bin/eventhandler_linux.cc
@@ -96,6 +96,11 @@ Dart_Port EventHandlerImplementation::PortFor(intptr_t fd) {
}
+bool EventHandlerImplementation::IsListeningSocket(intptr_t fd) {
+ return (port_map_[fd].mask & (1 << kListeningSocket)) != 0;
+}
+
+
void EventHandlerImplementation::RegisterFdWakeup(intptr_t id,
Dart_Port dart_port,
intptr_t data) {
@@ -136,17 +141,15 @@ void EventHandlerImplementation::WakeupHandler(intptr_t id,
void EventHandlerImplementation::SetPollEvents(struct pollfd* pollfds,
intptr_t mask) {
- /*
- * We do not set POLLERR and POLLHUP explicitly since they are triggered
- * anyway.
- */
- pollfds->events |= POLLRDHUP;
+ // Do not ask for POLLERR and POLLHUP explicitly as they are
+ // triggered anyway.
if ((mask & (1 << kInEvent)) != 0) {
pollfds->events |= POLLIN;
}
if ((mask & (1 << kOutEvent)) != 0) {
pollfds->events |= POLLOUT;
}
+ pollfds->events |= POLLRDHUP;
}
@@ -213,27 +216,29 @@ void EventHandlerImplementation::HandleInterruptFd() {
intptr_t EventHandlerImplementation::GetPollEvents(struct pollfd* pollfd) {
intptr_t event_mask = 0;
- /*
- * We prioritize the events in the following order.
- */
- if ((pollfd->revents & POLLIN) != 0) {
- if (FDUtils::AvailableBytes(pollfd->fd) != 0) {
- event_mask = (1 << kInEvent);
- } else if (((pollfd->revents & POLLHUP) != 0) ||
- ((pollfd->revents & POLLRDHUP) != 0)) {
- event_mask = (1 << kCloseEvent);
- } else if ((pollfd->revents & POLLERR) != 0) {
- event_mask = (1 << kErrorEvent);
- } else {
- /*
- * Accept event.
- */
- event_mask = (1 << kInEvent);
+ if (IsListeningSocket(pollfd->fd)) {
+ // For listening sockets the POLLIN event indicate that there are
+ // connections ready for accept unless accompanied with one of the
+ // other flags.
+ if ((pollfd->revents & POLLIN) != 0) {
+ if ((pollfd->revents & POLLHUP) != 0) event_mask |= (1 << kCloseEvent);
+ if ((pollfd->revents & POLLERR) != 0) event_mask |= (1 << kErrorEvent);
+ if (event_mask == 0) event_mask |= (1 << kInEvent);
+ }
+ } else {
+ // Prioritize data events over close and error events.
+ if ((pollfd->revents & POLLIN) != 0) {
+ if (FDUtils::AvailableBytes(pollfd->fd) != 0) {
+ event_mask = (1 << kInEvent);
+ } else if (((pollfd->revents & POLLHUP) != 0) ||
+ ((pollfd->revents & POLLRDHUP) != 0)) {
+ event_mask = (1 << kCloseEvent);
+ } else if ((pollfd->revents & POLLERR) != 0) {
+ event_mask = (1 << kErrorEvent);
+ }
}
- }
- if ((pollfd->revents & POLLOUT) != 0) {
- event_mask |= (1 << kOutEvent);
+ if ((pollfd->revents & POLLOUT) != 0) event_mask |= (1 << kOutEvent);
}
return event_mask;
« no previous file with comments | « runtime/bin/eventhandler_linux.h ('k') | runtime/bin/eventhandler_macos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698