diff options
author | Jeff Brown <jeffbrown@google.com> | 2010-09-16 17:04:52 -0700 |
---|---|---|
committer | Alex Ray <aray@google.com> | 2013-07-30 13:56:54 -0700 |
commit | 171bf9e69792f4796e27334c8a97dbd8576ad78a (patch) | |
tree | 0f87a1626d21e2871aa54b4be08a686645061b3f /libs | |
parent | 7901eb25c60b1df00050d6c3772505d8dcfcdab9 (diff) | |
download | system_core-171bf9e69792f4796e27334c8a97dbd8576ad78a.zip system_core-171bf9e69792f4796e27334c8a97dbd8576ad78a.tar.gz system_core-171bf9e69792f4796e27334c8a97dbd8576ad78a.tar.bz2 |
Ensure input dispatcher and native looper handles EINTR.
Change-Id: I0a42db5f273b9bfe4ab174e4ee65d5d852f9f6bc
Diffstat (limited to 'libs')
-rw-r--r-- | libs/utils/Looper.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/libs/utils/Looper.cpp b/libs/utils/Looper.cpp index fd287da..4aa50d6 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); |