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
This commit is contained in:
Tom Cherry 2020-05-27 10:46:37 -07:00
parent f8f95a41f4
commit 3e61a1368a
6 changed files with 29 additions and 29 deletions

View File

@ -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<FlushToResult(const LogBufferElement* element)>& filter) = 0;
const std::function<FilterResult(const LogBufferElement* element)>& filter) = 0;
virtual bool Clear(log_id_t id, uid_t uid) = 0;
virtual unsigned long GetSize(log_id_t id) = 0;

View File

@ -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);

View File

@ -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) {

View File

@ -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_;

View File

@ -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<FlushToResult(const LogBufferElement* element)>& filter) {
const std::function<FilterResult(const LogBufferElement* element)>& filter) {
auto shared_lock = SharedLock{lock_};
std::list<LogBufferElement>::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;
}
}

View File

@ -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<FlushToResult(const LogBufferElement* element)>& filter) override;
const std::function<FilterResult(const LogBufferElement* element)>& filter) override;
bool Clear(log_id_t id, uid_t uid) override;
unsigned long GetSize(log_id_t id) override;