Index: dart/runtime/bin/eventhandler_macos.cc |
diff --git a/dart/runtime/bin/eventhandler_macos.cc b/dart/runtime/bin/eventhandler_macos.cc |
index 8066acb24f9da936b306382fd265eecdd29708e5..911cbada65b87ca8d8051f577ea61b846843f012 100644 |
--- a/dart/runtime/bin/eventhandler_macos.cc |
+++ b/dart/runtime/bin/eventhandler_macos.cc |
@@ -136,7 +136,8 @@ EventHandlerImplementation::~EventHandlerImplementation() { |
} |
-SocketData* EventHandlerImplementation::GetSocketData(intptr_t fd) { |
+SocketData* EventHandlerImplementation::GetSocketData(intptr_t fd, |
+ bool is_listening) { |
ASSERT(fd >= 0); |
HashMap::Entry* entry = socket_map_.Lookup( |
GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd), true); |
@@ -145,7 +146,7 @@ SocketData* EventHandlerImplementation::GetSocketData(intptr_t fd) { |
if (sd == NULL) { |
// If there is no data in the hash map for this file descriptor a |
// new SocketData for the file descriptor is inserted. |
- sd = new SocketData(fd); |
+ sd = new SocketData(fd, is_listening); |
entry->value = sd; |
} |
ASSERT(fd == sd->fd()); |
@@ -185,7 +186,10 @@ void EventHandlerImplementation::HandleInterruptFd() { |
} else if (msg[i].id == kShutdownId) { |
shutdown_ = true; |
} else { |
- SocketData* sd = GetSocketData(msg[i].id); |
+ ASSERT((msg[i].data & COMMAND_MASK) != 0); |
+ |
+ SocketData* sd = GetSocketData( |
+ msg[i].id, IS_LISTENING_SOCKET(msg[i].data)); |
if (IS_COMMAND(msg[i].data, kShutdownReadCommand)) { |
// Close the socket for reading. |
shutdown(sd->fd(), SHUT_RD); |
@@ -207,14 +211,17 @@ void EventHandlerImplementation::HandleInterruptFd() { |
AddToKqueue(kqueue_fd_, sd); |
} |
} |
- } else { |
- ASSERT_NO_COMMAND(msg[i].data); |
+ } else if (IS_COMMAND(msg[i].data, kSetEventMaskCommand)) { |
+ // `events` can only have kInEvent/kOutEvent flags set. |
+ intptr_t events = msg[i].data & EVENT_MASK; |
+ ASSERT(0 == (events & ~(1 << kInEvent | 1 << kOutEvent))); |
+ |
// Setup events to wait for. |
- ASSERT((msg[i].data > 0) && (msg[i].data < kIntptrMax)); |
ASSERT(sd->port() == 0); |
- sd->SetPortAndMask(msg[i].dart_port, |
- static_cast<intptr_t>(msg[i].data)); |
+ sd->SetPortAndMask(msg[i].dart_port, events); |
AddToKqueue(kqueue_fd_, sd); |
+ } else { |
+ UNREACHABLE(); |
} |
} |
} |