summaryrefslogtreecommitdiffstats
path: root/libs/rs
diff options
context:
space:
mode:
authorBryan Mawhinney <bryanmawhinney@google.com>2010-12-05 17:21:07 +0000
committerBryan Mawhinney <bryanmawhinney@google.com>2010-12-05 17:21:07 +0000
commit8ea061bcdd15588603ed4dbd720e493ec1d62a89 (patch)
treead9453eb918b907e328a25b4bb578aa0601c6811 /libs/rs
parentbcdf40b42fb8a4313461233d2db1eb959e2c6a70 (diff)
downloadframeworks_base-8ea061bcdd15588603ed4dbd720e493ec1d62a89.zip
frameworks_base-8ea061bcdd15588603ed4dbd720e493ec1d62a89.tar.gz
frameworks_base-8ea061bcdd15588603ed4dbd720e493ec1d62a89.tar.bz2
Prevent message overrun in LocklessCommandFifo.
The previous logic in makeSpace and makeSpaceNonBlocking was incorrect (probably a typo). We shouldn't loop if looping will overwrite unread messages, or if we would make the buffer appear empty (mPut == mGet). Change-Id: Iabc82ca94a585a7041069db97cbed7709f2d388f
Diffstat (limited to 'libs/rs')
-rw-r--r--libs/rs/rsLocklessFifo.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/libs/rs/rsLocklessFifo.cpp b/libs/rs/rsLocklessFifo.cpp
index e87525e..804c767 100644
--- a/libs/rs/rsLocklessFifo.cpp
+++ b/libs/rs/rsLocklessFifo.cpp
@@ -166,7 +166,7 @@ bool LocklessCommandFifo::makeSpaceNonBlocking(uint32_t bytes) {
//dumpState("make space non-blocking");
if ((mPut+bytes) > mEnd) {
// Need to loop regardless of where get is.
- if ((mGet > mPut) && (mBuffer+4 >= mGet)) {
+ if ((mGet > mPut) || (mBuffer+4 >= mGet)) {
return false;
}
@@ -189,7 +189,7 @@ void LocklessCommandFifo::makeSpace(uint32_t bytes) {
//dumpState("make space");
if ((mPut+bytes) > mEnd) {
// Need to loop regardless of where get is.
- while ((mGet > mPut) && (mBuffer+4 >= mGet)) {
+ while ((mGet > mPut) || (mBuffer+4 >= mGet)) {
usleep(100);
}
@@ -210,4 +210,3 @@ void LocklessCommandFifo::makeSpace(uint32_t bytes) {
void LocklessCommandFifo::dumpState(const char *s) const {
LOGV("%s %p put %p, get %p, buf %p, end %p", s, this, mPut, mGet, mBuffer, mEnd);
}
-