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

Commit 5392aac9 authored by Mark Salyzyn's avatar Mark Salyzyn
Browse files

logd: deal with sloppy leading expire messages

The odds of chatty content also leading the logs is pretty high eg:

 1799 12017 I logd: uid=10007 chatty comm=Binder_B, expire 4 lines
 1799  1829 I logd: uid=10007 chatty comm=Binder_2, expire 4 lines
 1919 20637 I logd: uid=10007 chatty comm=m.sersistent, expire 1 line
 1919 20638 I logd: uid=10007 chatty comm=s.persistent, expire 1 line
 1919  2316 I logd: uid=10007 chatty comm=UlrDispatch, expire 4 lines
19379 20634 I logd: uid=10045 chatty, expire 14 lines
19379 19388 I logd: uid=10045 chatty comm=lizerDaemon, expire 4 lines
  591  4396 I logd: uid=1000 chatty comm=Thread-220, expire 5 lines
  591  1377 I logd: uid=1000 chatty comm=Thread-92, expire 4 lines
 1919  2267 I logd: uid=10007 chatty comm=WifiScanner, expire 4 lines
  591  4397 I logd: uid=1000 chatty comm=DhcpClient, expire 4 lines
  591  4398 I logd: uid=1000 chatty comm=Thread-222, expire 4 lines
  226   580 D CommandListener: Setting iface cfg

Change-Id: I5ab24bc7bf5d2690bae7e789831b07f23ff8bcc6
parent ce817c38
Loading
Loading
Loading
Loading
+15 −10
Original line number Diff line number Diff line
@@ -417,8 +417,6 @@ void LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) {
                continue;
            }

            leading = false;

            if (hasBlacklist && mPrune.naughty(e)) {
                last.clear(e);
                it = erase(it);
@@ -448,6 +446,7 @@ void LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) {
            }

            if (e->getUid() != worst) {
                leading = false;
                if (start != log_time::EPOCH) {
                    static const timespec too_old = {
                        EXPIRE_HOUR_THRESHOLD * 60 * 60, 0
@@ -479,6 +478,11 @@ void LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) {
            kick = true;

            unsigned short len = e->getMsgLen();

            // do not create any leading drops
            if (leading) {
                it = erase(it);
            } else {
                stats.drop(e);
                e->setDropped(1);
                if (last.merge(e, 1)) {
@@ -489,6 +493,7 @@ void LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) {
                    last.add(e);
                    ++it;
                }
            }
            if (worst_sizes < second_worst_sizes) {
                break;
            }