Merge "logd: cap out-of-order entry search"
diff --git a/logd/LogBuffer.cpp b/logd/LogBuffer.cpp
index 0984e81..0c7019a 100644
--- a/logd/LogBuffer.cpp
+++ b/logd/LogBuffer.cpp
@@ -1091,8 +1091,10 @@
it = mLogElements.begin();
} else {
LogBufferElementCollection::iterator last;
- // 30 second limit to continue search for out-of-order entries.
- log_time min = start - log_time(30, 0);
+ // 3 second limit to continue search for out-of-order entries.
+ log_time min = start - log_time(3, 0);
+ // Cap to 300 iterations we look back for out-of-order entries.
+ size_t count = 300;
// Client wants to start from some specified time. Chances are
// we are better off starting from the end of the time sorted list.
for (last = it = mLogElements.end(); it != mLogElements.begin();
@@ -1101,7 +1103,7 @@
LogBufferElement* element = *it;
if (element->getRealTime() > start) {
last = it;
- } else if (element->getRealTime() < min) {
+ } else if (!--count || (element->getRealTime() < min)) {
break;
}
}