Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 775cd222 authored by Mark Salyzyn's avatar Mark Salyzyn
Browse files

logd: cap out-of-order entry search

Reduce the period we are willing to look back at for out-of-order
entries.  Cap the number of iterations we are willing to look back
for out-of-order entries to 300.

Test: gTest liblog-unit-tests, logd-unit-tests and logcat-unit-tests
Bug: 36875387
Bug: 36874561
Bug: 36861142
Change-Id: Icee289dfc0a37ccab9912dc8ab40a10ef3967b7a
parent e4b2d28b
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -1093,8 +1093,10 @@ log_time LogBuffer::flushTo(SocketClient* reader, const log_time& start,
        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();
@@ -1103,7 +1105,7 @@ log_time LogBuffer::flushTo(SocketClient* reader, const log_time& start,
            LogBufferElement* element = *it;
            if (element->getRealTime() > start) {
                last = it;
            } else if (element->getRealTime() < min) {
            } else if (!--count || (element->getRealTime() < min)) {
                break;
            }
        }