diff options
author | 2018-01-23 14:06:58 -0800 | |
---|---|---|
committer | 2018-01-23 14:24:21 -0800 | |
commit | 96f4dc41fee6d94adb3f44fcb9c72ea1ba414060 (patch) | |
tree | 224cf4abd41da3762667e235c590ce9f65252bbe | |
parent | 2a96fe8541b7179e923b6edd27dfe1b8ceb6988e (diff) |
Add missing TEMP_FAILURE_RETRYs in dt_fd_forward
There were several syscalls that should have had a TEMP_FAILURE_RETRY
but did not. This could cause the connection to be dropped
unexpectedly if there was a signal.
Test: build
Test: ./tools/dt_fds_forward.py \
./test/run-test --host --dev 001-HelloWorld
Test: jdb -attach localhost:12345
Test: kill -3 <pid of dalvikvm>
Change-Id: I62a3409d3e2947db1c7142547c925d1d2ba9eecd
-rw-r--r-- | dt_fd_forward/dt_fd_forward.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/dt_fd_forward/dt_fd_forward.cc b/dt_fd_forward/dt_fd_forward.cc index cf3088dc60..1cf31a75a5 100644 --- a/dt_fd_forward/dt_fd_forward.cc +++ b/dt_fd_forward/dt_fd_forward.cc @@ -162,7 +162,7 @@ IOResult FdForwardTransport::ReadFullyWithoutChecks(void* data, size_t ndata) { IOResult FdForwardTransport::ReadUpToMax(void* data, size_t ndata, /*out*/size_t* read_amount) { CHECK_GE(read_fd_.get(), 0); int avail; - int res = ioctl(read_fd_, FIONREAD, &avail); + int res = TEMP_FAILURE_RETRY(ioctl(read_fd_, FIONREAD, &avail)); if (res < 0) { DT_IO_ERROR("Failed ioctl(read_fd_, FIONREAD, &avail)"); return IOResult::kError; @@ -172,7 +172,7 @@ IOResult FdForwardTransport::ReadUpToMax(void* data, size_t ndata, /*out*/size_t if (*read_amount == 0) { // Check if the read would cause an EOF. struct pollfd pollfd = { read_fd_, POLLRDHUP, 0 }; - res = poll(&pollfd, /*nfds*/1, /*timeout*/0); + res = TEMP_FAILURE_RETRY(poll(&pollfd, /*nfds*/1, /*timeout*/0)); if (res < 0 || (pollfd.revents & POLLERR) == POLLERR) { DT_IO_ERROR("Failed poll on read fd."); return IOResult::kError; @@ -214,13 +214,13 @@ IOResult FdForwardTransport::ReadFully(void* data, size_t ndata) { // No more data. Sleep without locks until more is available. We don't actually check for any // errors since possible ones are (1) the read_fd_ is closed or wakeup happens which are both // fine since the wakeup_fd_ or the poll failing will wake us up. - int poll_res = poll(pollfds, 2, -1); + int poll_res = TEMP_FAILURE_RETRY(poll(pollfds, 2, -1)); if (poll_res < 0) { DT_IO_ERROR("Failed to poll!"); } // Clear the wakeup_fd regardless. uint64_t val; - int unused = read(wakeup_fd_, &val, sizeof(val)); + int unused = TEMP_FAILURE_RETRY(read(wakeup_fd_, &val, sizeof(val))); DCHECK(unused == sizeof(val) || errno == EAGAIN); if (poll_res < 0) { return IOResult::kError; |