BitTube::read now handles EAGAIN
Change-Id: Iacda2386342ba0727bbf278f6c597488d5467bb8
diff --git a/core/jni/android_hardware_SensorManager.cpp b/core/jni/android_hardware_SensorManager.cpp
index 10ceb7b..202abf6 100644
--- a/core/jni/android_hardware_SensorManager.cpp
+++ b/core/jni/android_hardware_SensorManager.cpp
@@ -126,7 +126,7 @@
ASensorEvent event;
res = queue->read(&event, 1);
- if (res == -EAGAIN) {
+ if (res == 0) {
res = queue->waitForEvent();
if (res != NO_ERROR)
return -1;
diff --git a/libs/gui/BitTube.cpp b/libs/gui/BitTube.cpp
index c632b43..fa8d0ea 100644
--- a/libs/gui/BitTube.cpp
+++ b/libs/gui/BitTube.cpp
@@ -97,6 +97,11 @@
len = ::read(mReceiveFd, vaddr, size);
err = len < 0 ? errno : 0;
} while (err == EINTR);
+ if (err == EAGAIN || err == EWOULDBLOCK) {
+ // EAGAIN means that we have non-blocking I/O but there was
+ // no data to be read. Nothing the client should care about.
+ return 0;
+ }
return err == 0 ? len : -err;
}