Index: runtime/bin/eventhandler_macos.h |
diff --git a/runtime/bin/eventhandler_macos.h b/runtime/bin/eventhandler_macos.h |
index cb765c64c8bf8c92aed931a91af9e50971e4b42d..96865669c050e5ad4f5333e904decf2197719e3a 100644 |
--- a/runtime/bin/eventhandler_macos.h |
+++ b/runtime/bin/eventhandler_macos.h |
@@ -10,6 +10,7 @@ |
#endif |
#include <unistd.h> |
+#include <errno.h> |
#include <sys/event.h> // NOLINT |
#include <sys/socket.h> |
@@ -27,21 +28,13 @@ class InterruptMessage { |
}; |
-enum PortDataFlags { |
- kClosedRead = 0, |
- kClosedWrite = 1, |
-}; |
- |
- |
class SocketData { |
public: |
explicit SocketData(intptr_t fd) |
: fd_(fd), |
port_(0), |
mask_(0), |
- flags_(0), |
- read_tracked_by_kqueue_(false), |
- write_tracked_by_kqueue_(false) { |
+ tracked_by_kqueue_(false) { |
ASSERT(fd_ != -1); |
} |
@@ -50,29 +43,21 @@ class SocketData { |
void ShutdownRead() { |
shutdown(fd_, SHUT_RD); |
- MarkClosedRead(); |
} |
void ShutdownWrite() { |
shutdown(fd_, SHUT_WR); |
- MarkClosedWrite(); |
} |
void Close() { |
port_ = 0; |
mask_ = 0; |
- flags_ = 0; |
close(fd_); |
fd_ = -1; |
} |
bool IsListeningSocket() { return (mask_ & (1 << kListeningSocket)) != 0; } |
bool IsPipe() { return (mask_ & (1 << kPipe)) != 0; } |
- bool IsClosedRead() { return (flags_ & (1 << kClosedRead)) != 0; } |
- bool IsClosedWrite() { return (flags_ & (1 << kClosedWrite)) != 0; } |
- |
- void MarkClosedRead() { flags_ |= (1 << kClosedRead); } |
- void MarkClosedWrite() { flags_ |= (1 << kClosedWrite); } |
void SetPortAndMask(Dart_Port port, intptr_t mask) { |
ASSERT(fd_ != -1); |
@@ -83,22 +68,16 @@ class SocketData { |
intptr_t fd() { return fd_; } |
Dart_Port port() { return port_; } |
intptr_t mask() { return mask_; } |
- bool read_tracked_by_kqueue() { return read_tracked_by_kqueue_; } |
- void set_read_tracked_by_kqueue(bool value) { |
- read_tracked_by_kqueue_ = value; |
- } |
- bool write_tracked_by_kqueue() { return write_tracked_by_kqueue_; } |
- void set_write_tracked_by_kqueue(bool value) { |
- write_tracked_by_kqueue_ = value; |
+ bool tracked_by_kqueue() { return tracked_by_kqueue_; } |
+ void set_tracked_by_kqueue(bool value) { |
+ tracked_by_kqueue_ = value; |
} |
private: |
intptr_t fd_; |
Dart_Port port_; |
intptr_t mask_; |
- intptr_t flags_; |
- bool read_tracked_by_kqueue_; |
- bool write_tracked_by_kqueue_; |
+ bool tracked_by_kqueue_; |
}; |
@@ -109,7 +88,7 @@ class EventHandlerImplementation { |
// Gets the socket data structure for a given file |
// descriptor. Creates a new one if one is not found. |
- SocketData* GetSocketData(intptr_t fd); |
+ SocketData* GetSocketData(intptr_t fd, bool* is_new); |
void SendData(intptr_t id, Dart_Port dart_port, int64_t data); |
void Start(EventHandler* handler); |
void Shutdown(); |