| 1279 | } |
| 1280 | |
| 1281 | Result<uint64_t> Wait() override { |
| 1282 | if (pipe_.rfd.closed()) { |
| 1283 | // Already closed |
| 1284 | return ClosedPipe(); |
| 1285 | } |
| 1286 | uint64_t payload = 0; |
| 1287 | char* buf = reinterpret_cast<char*>(&payload); |
| 1288 | auto buf_size = static_cast<int64_t>(sizeof(payload)); |
| 1289 | while (buf_size > 0) { |
| 1290 | int64_t n_read = PIPE_READ(pipe_.rfd.fd(), buf, static_cast<uint32_t>(buf_size)); |
| 1291 | if (n_read < 0) { |
| 1292 | if (errno == EINTR) { |
| 1293 | continue; |
| 1294 | } |
| 1295 | if (pipe_.rfd.closed()) { |
| 1296 | return ClosedPipe(); |
| 1297 | } |
| 1298 | return IOErrorFromErrno(errno, "Failed reading from self-pipe"); |
| 1299 | } |
| 1300 | buf += n_read; |
| 1301 | buf_size -= n_read; |
| 1302 | } |
| 1303 | if (payload == kEofPayload && please_shutdown_.load()) { |
| 1304 | RETURN_NOT_OK(pipe_.rfd.Close()); |
| 1305 | return ClosedPipe(); |
| 1306 | } |
| 1307 | return payload; |
| 1308 | } |
| 1309 | |
| 1310 | // XXX return StatusCode from here? |
| 1311 | void Send(uint64_t payload) override { |
nothing calls this directly
no test coverage detected