summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2010-09-16 17:12:31 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-09-16 17:12:31 -0700
commit3b6dda9e19cf7c9073f52da2c25ef79ee80a83a6 (patch)
treec9d6649bc2159a19feff7ce505e4d8f595aa13b6 /libs
parent42f6ea4f5e94ceca987aeac89fbf4b55a7156b08 (diff)
parentf67f29903680e7a33af020dbeb80697ad619b26e (diff)
downloadframeworks_native-3b6dda9e19cf7c9073f52da2c25ef79ee80a83a6.zip
frameworks_native-3b6dda9e19cf7c9073f52da2c25ef79ee80a83a6.tar.gz
frameworks_native-3b6dda9e19cf7c9073f52da2c25ef79ee80a83a6.tar.bz2
Merge "Ensure input dispatcher and native looper handles EINTR." into gingerbread
Diffstat (limited to 'libs')
-rw-r--r--libs/ui/InputTransport.cpp11
-rw-r--r--libs/utils/Looper.cpp14
2 files changed, 19 insertions, 6 deletions
diff --git a/libs/ui/InputTransport.cpp b/libs/ui/InputTransport.cpp
index 4c402dc..2c6346e 100644
--- a/libs/ui/InputTransport.cpp
+++ b/libs/ui/InputTransport.cpp
@@ -131,7 +131,10 @@ status_t InputChannel::openInputChannelPair(const String8& name,
}
status_t InputChannel::sendSignal(char signal) {
- ssize_t nWrite = ::write(mSendPipeFd, & signal, 1);
+ ssize_t nWrite;
+ do {
+ nWrite = ::write(mSendPipeFd, & signal, 1);
+ } while (nWrite == -1 && errno == EINTR);
if (nWrite == 1) {
#if DEBUG_CHANNEL_SIGNALS
@@ -147,7 +150,11 @@ status_t InputChannel::sendSignal(char signal) {
}
status_t InputChannel::receiveSignal(char* outSignal) {
- ssize_t nRead = ::read(mReceivePipeFd, outSignal, 1);
+ ssize_t nRead;
+ do {
+ nRead = ::read(mReceivePipeFd, outSignal, 1);
+ } while (nRead == -1 && errno == EINTR);
+
if (nRead == 1) {
#if DEBUG_CHANNEL_SIGNALS
LOGD("channel '%s' ~ received signal '%c'", mName.string(), *outSignal);
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);