diff options
author | Ben Fennema <fennema@google.com> | 2017-05-04 14:26:35 -0700 |
---|---|---|
committer | Ben Fennema <fennema@google.com> | 2017-06-19 21:30:15 -0700 |
commit | 78273fc2c49a6221beeb5af45be7439420ded990 (patch) | |
tree | 6aceaec1b4e5db03a9fe3b78ce235b1266370d7e | |
parent | 0e295b8786f1563d097219b26fa3c73408daa6d5 (diff) | |
download | contexthub-78273fc2c49a6221beeb5af45be7439420ded990.tar.gz |
contexthubhal: properly deal with poll errors
Bug: 37998312
Test: builds
Change-Id: If8beaabd50e25a6c91d70ed5e8ffe4a80a0a40e1
Signed-off-by: Ben Fennema <fennema@google.com>
-rw-r--r-- | contexthubhal/nanohubhal.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/contexthubhal/nanohubhal.cpp b/contexthubhal/nanohubhal.cpp index fa3c5f8f..7764253b 100644 --- a/contexthubhal/nanohubhal.cpp +++ b/contexthubhal/nanohubhal.cpp @@ -139,8 +139,11 @@ static void wait_on_dev_lock(pollfd &pfd) { discard_inotify_evt(pfd); while (access(NANOHUB_LOCK_FILE, F_OK) == 0) { ALOGW("Nanohub is locked; blocking read thread"); - int ret = poll(&pfd, 1, 5000); - if (ret > 0) { + int ret = TEMP_FAILURE_RETRY(poll(&pfd, 1, 5000)); + if (ret < 0) { + ALOGE("poll returned with an error: %s", strerror(errno)); + break; + } else if (ret > 0) { discard_inotify_evt(pfd); } } @@ -226,10 +229,12 @@ void* NanoHub::runDeviceRx() setDebugFlags(property_get_int32("persist.nanohub.debug", 0)); while (1) { - int ret = poll(myFds, numPollFds, -1); - if (ret <= 0) { - ALOGD("poll returned with an error: %s", strerror(errno)); + int ret = TEMP_FAILURE_RETRY(poll(myFds, numPollFds, -1)); + if (ret == 0) continue; + else if (ret < 0) { + ALOGE("poll returned with an error: %s", strerror(errno)); + break; } if (hasInotify) { |