summaryrefslogtreecommitdiff
path: root/libs/utils/Looper.cpp
diff options
context:
space:
mode:
author Jeff Brown <jeffbrown@google.com> 2010-09-16 17:12:31 -0700
committer Android (Google) Code Review <android-gerrit@google.com> 2010-09-16 17:12:31 -0700
commit1ac48eabd39e0cfd087ddf2c3b6ba8e56803bdd4 (patch)
tree0308ce43dfd43cc64679911169f99f269ac7d0a0 /libs/utils/Looper.cpp
parent9c2587104ae259b9fa6a3525063197cc08e8820b (diff)
parent7dae0e47abb5c1fb852c10b3ba0bc6464dd76e96 (diff)
Merge "Ensure input dispatcher and native looper handles EINTR." into gingerbread
Diffstat (limited to 'libs/utils/Looper.cpp')
-rw-r--r--libs/utils/Looper.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/libs/utils/Looper.cpp b/libs/utils/Looper.cpp
index fd287da51f53..4aa50d675f16 100644
--- a/libs/utils/Looper.cpp
+++ b/libs/utils/Looper.cpp
@@ -162,9 +162,11 @@ int Looper::pollInner(int timeoutMillis) {
struct epoll_event eventItems[EPOLL_MAX_EVENTS];
int eventCount = epoll_wait(mEpollFd, eventItems, EPOLL_MAX_EVENTS, timeoutMillis);
if (eventCount < 0) {
- if (errno != EINTR) {
- LOGW("Poll failed with an unexpected error, errno=%d", errno);
+ if (errno == EINTR) {
+ return ALOOPER_POLL_WAKE;
}
+
+ LOGW("Poll failed with an unexpected error, errno=%d", errno);
return ALOOPER_POLL_ERROR;
}
@@ -196,7 +198,7 @@ int Looper::pollInner(int timeoutMillis) {
ssize_t nRead;
do {
nRead = read(mWakeReadPipeFd, buffer, sizeof(buffer));
- } while (nRead == sizeof(buffer));
+ } while ((nRead == -1 && errno == EINTR) || nRead == sizeof(buffer));
} else {
LOGW("Ignoring unexpected epoll events 0x%x on wake read pipe.", epollEvents);
}
@@ -272,7 +274,11 @@ void Looper::wake() {
LOGD("%p ~ wake", this);
#endif
- ssize_t nWrite = write(mWakeWritePipeFd, "W", 1);
+ ssize_t nWrite;
+ do {
+ nWrite = write(mWakeWritePipeFd, "W", 1);
+ } while (nWrite == -1 && errno == EINTR);
+
if (nWrite != 1) {
if (errno != EAGAIN) {
LOGW("Could not write wake signal, errno=%d", errno);