return errors properly in BitTube and SensorEventQueue

Change-Id: Idf31179f9fcc666e287c7b01b2007431cb60127d
This commit is contained in:
Mathias Agopian 2012-05-07 15:20:15 -07:00
parent 3410a85b15
commit 29267fe849
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;