From 3e61a1368af0cbcd760c20598870472c5117297f Mon Sep 17 00:00:00 2001 From: Tom Cherry Date: Wed, 27 May 2020 10:46:37 -0700 Subject: [PATCH] logd: rename FlushToResult to FilterResult This was a typo; the enum corresponds to the result of the 'Filter' function, not the 'FlushTo' function. Test: build Change-Id: Ib46f0646570b6dbaac17ae9fc95c990128cdbe72 --- logd/LogBuffer.h | 4 ++-- logd/LogReader.cpp | 12 ++++++------ logd/LogReaderThread.cpp | 28 ++++++++++++++-------------- logd/LogReaderThread.h | 4 ++-- logd/SimpleLogBuffer.cpp | 8 ++++---- logd/SimpleLogBuffer.h | 2 +- 6 files changed, 29 insertions(+), 29 deletions(-) diff --git a/logd/LogBuffer.h b/logd/LogBuffer.h index 7f1e1284e..d38c01840 100644 --- a/logd/LogBuffer.h +++ b/logd/LogBuffer.h @@ -27,7 +27,7 @@ class LogWriter; -enum class FlushToResult { +enum class FilterResult { kSkip, kStop, kWrite, @@ -48,7 +48,7 @@ class LogBuffer { virtual uint64_t FlushTo( LogWriter* writer, uint64_t start, pid_t* last_tid, // nullable - const std::function& filter) = 0; + const std::function& filter) = 0; virtual bool Clear(log_id_t id, uid_t uid) = 0; virtual unsigned long GetSize(log_id_t id) = 0; diff --git a/logd/LogReader.cpp b/logd/LogReader.cpp index 234ddc75b..26f2ed28a 100644 --- a/logd/LogReader.cpp +++ b/logd/LogReader.cpp @@ -172,26 +172,26 @@ bool LogReader::onDataAvailable(SocketClient* cli) { bool start_time_set = false; uint64_t last = sequence; auto log_find_start = [pid, logMask, start, &sequence, &start_time_set, - &last](const LogBufferElement* element) -> FlushToResult { + &last](const LogBufferElement* element) -> FilterResult { if (pid && pid != element->getPid()) { - return FlushToResult::kSkip; + return FilterResult::kSkip; } if ((logMask & (1 << element->getLogId())) == 0) { - return FlushToResult::kSkip; + return FilterResult::kSkip; } if (start == element->getRealTime()) { sequence = element->getSequence(); start_time_set = true; - return FlushToResult::kStop; + return FilterResult::kStop; } else { if (start < element->getRealTime()) { sequence = last; start_time_set = true; - return FlushToResult::kStop; + return FilterResult::kStop; } last = element->getSequence(); } - return FlushToResult::kSkip; + return FilterResult::kSkip; }; log_buffer_->FlushTo(socket_log_writer.get(), sequence, nullptr, log_find_start); diff --git a/logd/LogReaderThread.cpp b/logd/LogReaderThread.cpp index b2001b56b..8de9622ad 100644 --- a/logd/LogReaderThread.cpp +++ b/logd/LogReaderThread.cpp @@ -123,12 +123,12 @@ void LogReaderThread::ThreadFunction() { } // A first pass to count the number of elements -FlushToResult LogReaderThread::FilterFirstPass(const LogBufferElement* element) { +FilterResult LogReaderThread::FilterFirstPass(const LogBufferElement* element) { auto lock = std::lock_guard{reader_list_->reader_threads_lock()}; if (leading_dropped_) { if (element->getDropped()) { - return FlushToResult::kSkip; + return FilterResult::kSkip; } leading_dropped_ = false; } @@ -142,46 +142,46 @@ FlushToResult LogReaderThread::FilterFirstPass(const LogBufferElement* element) ++count_; } - return FlushToResult::kSkip; + return FilterResult::kSkip; } // A second pass to send the selected elements -FlushToResult LogReaderThread::FilterSecondPass(const LogBufferElement* element) { +FilterResult LogReaderThread::FilterSecondPass(const LogBufferElement* element) { auto lock = std::lock_guard{reader_list_->reader_threads_lock()}; start_ = element->getSequence(); if (skip_ahead_[element->getLogId()]) { skip_ahead_[element->getLogId()]--; - return FlushToResult::kSkip; + return FilterResult::kSkip; } if (leading_dropped_) { if (element->getDropped()) { - return FlushToResult::kSkip; + return FilterResult::kSkip; } leading_dropped_ = false; } // Truncate to close race between first and second pass if (non_block_ && tail_ && index_ >= count_) { - return FlushToResult::kStop; + return FilterResult::kStop; } if (!IsWatching(element->getLogId())) { - return FlushToResult::kSkip; + return FilterResult::kSkip; } if (pid_ && pid_ != element->getPid()) { - return FlushToResult::kSkip; + return FilterResult::kSkip; } if (start_time_ != log_time::EPOCH && element->getRealTime() <= start_time_) { - return FlushToResult::kSkip; + return FilterResult::kSkip; } if (release_) { - return FlushToResult::kStop; + return FilterResult::kStop; } if (!tail_) { @@ -191,7 +191,7 @@ FlushToResult LogReaderThread::FilterSecondPass(const LogBufferElement* element) ++index_; if (count_ > tail_ && index_ <= (count_ - tail_)) { - return FlushToResult::kSkip; + return FilterResult::kSkip; } if (!non_block_) { @@ -200,9 +200,9 @@ FlushToResult LogReaderThread::FilterSecondPass(const LogBufferElement* element) ok: if (!skip_ahead_[element->getLogId()]) { - return FlushToResult::kWrite; + return FilterResult::kWrite; } - return FlushToResult::kSkip; + return FilterResult::kSkip; } void LogReaderThread::cleanSkip_Locked(void) { diff --git a/logd/LogReaderThread.h b/logd/LogReaderThread.h index e48a3cab2..907bc83a7 100644 --- a/logd/LogReaderThread.h +++ b/logd/LogReaderThread.h @@ -63,8 +63,8 @@ class LogReaderThread { private: void ThreadFunction(); // flushTo filter callbacks - FlushToResult FilterFirstPass(const LogBufferElement* element); - FlushToResult FilterSecondPass(const LogBufferElement* element); + FilterResult FilterFirstPass(const LogBufferElement* element); + FilterResult FilterSecondPass(const LogBufferElement* element); std::condition_variable thread_triggered_condition_; LogBuffer* log_buffer_; diff --git a/logd/SimpleLogBuffer.cpp b/logd/SimpleLogBuffer.cpp index 1c834281d..d60805d8c 100644 --- a/logd/SimpleLogBuffer.cpp +++ b/logd/SimpleLogBuffer.cpp @@ -112,7 +112,7 @@ void SimpleLogBuffer::LogInternal(LogBufferElement&& elem) { uint64_t SimpleLogBuffer::FlushTo( LogWriter* writer, uint64_t start, pid_t* last_tid, - const std::function& filter) { + const std::function& filter) { auto shared_lock = SharedLock{lock_}; std::list::iterator it; @@ -146,11 +146,11 @@ uint64_t SimpleLogBuffer::FlushTo( } if (filter) { - FlushToResult ret = filter(&element); - if (ret == FlushToResult::kSkip) { + FilterResult ret = filter(&element); + if (ret == FilterResult::kSkip) { continue; } - if (ret == FlushToResult::kStop) { + if (ret == FilterResult::kStop) { break; } } diff --git a/logd/SimpleLogBuffer.h b/logd/SimpleLogBuffer.h index 9a2d01ab5..cd08acf69 100644 --- a/logd/SimpleLogBuffer.h +++ b/logd/SimpleLogBuffer.h @@ -37,7 +37,7 @@ class SimpleLogBuffer : public LogBuffer { uint16_t len) override; uint64_t FlushTo( LogWriter* writer, uint64_t start, pid_t* lastTid, - const std::function& filter) override; + const std::function& filter) override; bool Clear(log_id_t id, uid_t uid) override; unsigned long GetSize(log_id_t id) override;