OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef BIN_EVENTHANDLER_ANDROID_H_ | 5 #ifndef BIN_EVENTHANDLER_ANDROID_H_ |
6 #define BIN_EVENTHANDLER_ANDROID_H_ | 6 #define BIN_EVENTHANDLER_ANDROID_H_ |
7 | 7 |
8 #if !defined(BIN_EVENTHANDLER_H_) | 8 #if !defined(BIN_EVENTHANDLER_H_) |
9 #error Do not include eventhandler_android.h directly; | 9 #error Do not include eventhandler_android.h directly; |
10 #error use eventhandler.h instead. | 10 #error use eventhandler.h instead. |
11 #endif | 11 #endif |
12 | 12 |
13 #include <unistd.h> | 13 #include <errno.h> |
14 #include <sys/epoll.h> | 14 #include <sys/epoll.h> |
15 #include <sys/socket.h> | 15 #include <sys/socket.h> |
| 16 #include <unistd.h> |
16 | 17 |
17 #include "platform/hashmap.h" | 18 #include "platform/hashmap.h" |
| 19 #include "platform/signal_blocker.h" |
18 | 20 |
19 | 21 |
20 namespace dart { | 22 namespace dart { |
21 namespace bin { | 23 namespace bin { |
22 | 24 |
23 class InterruptMessage { | 25 class InterruptMessage { |
24 public: | 26 public: |
25 intptr_t id; | 27 intptr_t id; |
26 Dart_Port dart_port; | 28 Dart_Port dart_port; |
27 int64_t data; | 29 int64_t data; |
28 }; | 30 }; |
29 | 31 |
30 | 32 |
31 class SocketData { | 33 class SocketData { |
32 public: | 34 public: |
33 explicit SocketData(intptr_t fd) | 35 explicit SocketData(intptr_t fd) |
34 : fd_(fd), port_(0), mask_(0), tokens_(8) { | 36 : fd_(fd), port_(0), mask_(0), tokens_(8) { |
35 ASSERT(fd_ != -1); | 37 ASSERT(fd_ != -1); |
36 } | 38 } |
37 | 39 |
38 intptr_t GetPollEvents(); | 40 intptr_t GetPollEvents(); |
39 | 41 |
40 void Close() { | 42 void Close() { |
41 port_ = 0; | 43 port_ = 0; |
42 mask_ = 0; | 44 mask_ = 0; |
43 close(fd_); | 45 VOID_TEMP_FAILURE_RETRY(close(fd_)); |
44 fd_ = -1; | 46 fd_ = -1; |
45 } | 47 } |
46 | 48 |
47 void SetPortAndMask(Dart_Port port, intptr_t mask) { | 49 void SetPortAndMask(Dart_Port port, intptr_t mask) { |
48 ASSERT(fd_ != -1); | 50 ASSERT(fd_ != -1); |
49 port_ = port; | 51 port_ = port; |
50 mask_ = mask; | 52 mask_ = mask; |
51 } | 53 } |
52 | 54 |
53 intptr_t fd() { return fd_; } | 55 intptr_t fd() { return fd_; } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 TimeoutQueue timeout_queue_; | 105 TimeoutQueue timeout_queue_; |
104 bool shutdown_; | 106 bool shutdown_; |
105 int interrupt_fds_[2]; | 107 int interrupt_fds_[2]; |
106 int epoll_fd_; | 108 int epoll_fd_; |
107 }; | 109 }; |
108 | 110 |
109 } // namespace bin | 111 } // namespace bin |
110 } // namespace dart | 112 } // namespace dart |
111 | 113 |
112 #endif // BIN_EVENTHANDLER_ANDROID_H_ | 114 #endif // BIN_EVENTHANDLER_ANDROID_H_ |
OLD | NEW |