| 1219 | } |
| 1220 | |
| 1221 | int Socket::WaitEpollOut(int fd, bool pollin, const timespec* abstime) { |
| 1222 | if (!ValidFileDescriptor(fd)) { |
| 1223 | return 0; |
| 1224 | } |
| 1225 | // Do not need to check addressable since it will be called by |
| 1226 | // health checker which called `SetFailed' before |
| 1227 | const int expected_val = _epollout_butex->load(butil::memory_order_relaxed); |
| 1228 | if (_io_event.RegisterEvent(fd, pollin) != 0) { |
| 1229 | return -1; |
| 1230 | } |
| 1231 | |
| 1232 | int rc = bthread::butex_wait(_epollout_butex, expected_val, abstime); |
| 1233 | const int saved_errno = errno; |
| 1234 | if (rc < 0 && errno == EWOULDBLOCK) { |
| 1235 | // Could be writable or spurious wakeup |
| 1236 | rc = 0; |
| 1237 | } |
| 1238 | // Ignore return value since `fd' might have been removed |
| 1239 | // by `RemoveConsumer' in `SetFailed' |
| 1240 | butil::ignore_result(_io_event.UnregisterEvent(fd, pollin)); |
| 1241 | errno = saved_errno; |
| 1242 | // Could be writable or spurious wakeup (by former epollout) |
| 1243 | return rc; |
| 1244 | } |
| 1245 | |
| 1246 | int Socket::Connect(const timespec* abstime, |
| 1247 | int (*on_connect)(int, int, void*), void* data) { |
no test coverage detected