am 1ac48eab: Merge "Ensure input dispatcher and native looper handles EINTR." into gingerbread
Merge commit '1ac48eabd39e0cfd087ddf2c3b6ba8e56803bdd4' into gingerbread-plus-aosp * commit '1ac48eabd39e0cfd087ddf2c3b6ba8e56803bdd4': Ensure input dispatcher and native looper handles EINTR.
This commit is contained in:
@@ -131,7 +131,10 @@ status_t InputChannel::openInputChannelPair(const String8& name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
status_t InputChannel::sendSignal(char signal) {
|
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 (nWrite == 1) {
|
||||||
#if DEBUG_CHANNEL_SIGNALS
|
#if DEBUG_CHANNEL_SIGNALS
|
||||||
@@ -147,7 +150,11 @@ status_t InputChannel::sendSignal(char signal) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
status_t InputChannel::receiveSignal(char* outSignal) {
|
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 (nRead == 1) {
|
||||||
#if DEBUG_CHANNEL_SIGNALS
|
#if DEBUG_CHANNEL_SIGNALS
|
||||||
LOGD("channel '%s' ~ received signal '%c'", mName.string(), *outSignal);
|
LOGD("channel '%s' ~ received signal '%c'", mName.string(), *outSignal);
|
||||||
|
|||||||
@@ -162,9 +162,11 @@ int Looper::pollInner(int timeoutMillis) {
|
|||||||
struct epoll_event eventItems[EPOLL_MAX_EVENTS];
|
struct epoll_event eventItems[EPOLL_MAX_EVENTS];
|
||||||
int eventCount = epoll_wait(mEpollFd, eventItems, EPOLL_MAX_EVENTS, timeoutMillis);
|
int eventCount = epoll_wait(mEpollFd, eventItems, EPOLL_MAX_EVENTS, timeoutMillis);
|
||||||
if (eventCount < 0) {
|
if (eventCount < 0) {
|
||||||
if (errno != EINTR) {
|
if (errno == EINTR) {
|
||||||
LOGW("Poll failed with an unexpected error, errno=%d", errno);
|
return ALOOPER_POLL_WAKE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOGW("Poll failed with an unexpected error, errno=%d", errno);
|
||||||
return ALOOPER_POLL_ERROR;
|
return ALOOPER_POLL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,7 +198,7 @@ int Looper::pollInner(int timeoutMillis) {
|
|||||||
ssize_t nRead;
|
ssize_t nRead;
|
||||||
do {
|
do {
|
||||||
nRead = read(mWakeReadPipeFd, buffer, sizeof(buffer));
|
nRead = read(mWakeReadPipeFd, buffer, sizeof(buffer));
|
||||||
} while (nRead == sizeof(buffer));
|
} while ((nRead == -1 && errno == EINTR) || nRead == sizeof(buffer));
|
||||||
} else {
|
} else {
|
||||||
LOGW("Ignoring unexpected epoll events 0x%x on wake read pipe.", epollEvents);
|
LOGW("Ignoring unexpected epoll events 0x%x on wake read pipe.", epollEvents);
|
||||||
}
|
}
|
||||||
@@ -272,7 +274,11 @@ void Looper::wake() {
|
|||||||
LOGD("%p ~ wake", this);
|
LOGD("%p ~ wake", this);
|
||||||
#endif
|
#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 (nWrite != 1) {
|
||||||
if (errno != EAGAIN) {
|
if (errno != EAGAIN) {
|
||||||
LOGW("Could not write wake signal, errno=%d", errno);
|
LOGW("Could not write wake signal, errno=%d", errno);
|
||||||
|
|||||||
Reference in New Issue
Block a user