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
diff --git a/dt_fd_forward/dt_fd_forward.cc b/dt_fd_forward/dt_fd_forward.cc
index cf3088d..1cf31a7 100644
--- a/dt_fd_forward/dt_fd_forward.cc
+++ b/dt_fd_forward/dt_fd_forward.cc
@@ -162,7 +162,7 @@
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 @@
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 @@
// 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;