Merge "return errors properly in BitTube and SensorEventQueue" into jb-dev

This commit is contained in:
Mathias Agopian 2012-05-07 20:09:20 -07:00 committed by Android (Google) Code Review
commit ddcb1c2bbd
2 changed files with 11 additions and 6 deletions

View File

@ -140,8 +140,7 @@ ssize_t BitTube::sendObjects(const sp<BitTube>& tube,
ssize_t size = tube->write(vaddr, objSize);
if (size < 0) {
// error occurred
numObjects = -size;
break;
return size;
} else if (size == 0) {
// no more space
break;
@ -160,8 +159,7 @@ ssize_t BitTube::recvObjects(const sp<BitTube>& tube,
ssize_t size = tube->read(vaddr, objSize);
if (size < 0) {
// error occurred
numObjects = -size;
break;
return size;
} else if (size == 0) {
// no more messages
break;

View File

@ -79,14 +79,21 @@ status_t SensorEventQueue::waitForEvent() const
const int fd = getFd();
sp<Looper> looper(getLooper());
int events;
int32_t result;
do {
result = looper->pollOnce(-1);
if (result == ALOOPER_EVENT_ERROR) {
result = looper->pollOnce(-1, NULL, &events, NULL);
if (result == ALOOPER_POLL_ERROR) {
ALOGE("SensorEventQueue::waitForEvent error (errno=%d)", errno);
result = -EPIPE; // unknown error, so we make up one
break;
}
if (events & ALOOPER_EVENT_HANGUP) {
// the other-side has died
ALOGE("SensorEventQueue::waitForEvent error HANGUP");
result = -EPIPE; // unknown error, so we make up one
break;
}
} while (result != fd);
return (result == fd) ? status_t(NO_ERROR) : result;