logging/WriterFrontend: No need for explicit CleanupWriteBuffer()

Any pending records will be cleaned in the destructor of WriterFrontend
and WriteBuffer, no need to do this explicitly.
This commit is contained in:
Arne Welzel 2024-08-30 10:45:04 +02:00
parent a9290cc031
commit f0ab10a46c
2 changed files with 1 additions and 14 deletions

View file

@ -132,7 +132,6 @@ WriterFrontend::~WriterFrontend() {
void WriterFrontend::Stop() { void WriterFrontend::Stop() {
if ( disabled ) { if ( disabled ) {
CleanupWriteBuffer();
return; return;
} }
@ -198,10 +197,8 @@ void WriterFrontend::Write(detail::LogRecord&& arg_vals) {
} }
void WriterFrontend::FlushWriteBuffer() { void WriterFrontend::FlushWriteBuffer() {
if ( disabled ) { if ( disabled )
CleanupWriteBuffer();
return; return;
}
if ( write_buffer.Empty() ) if ( write_buffer.Empty() )
// Nothing to do. // Nothing to do.
@ -248,6 +245,4 @@ void WriterFrontend::Rotate(const char* rotated_path, double open, double close,
log_mgr->FinishedRotation(this, nullptr, nullptr, 0, 0, false, terminating); log_mgr->FinishedRotation(this, nullptr, nullptr, 0, 0, false, terminating);
} }
void WriterFrontend::CleanupWriteBuffer() { write_buffer.Clear(); }
} // namespace zeek::logging } // namespace zeek::logging

View file

@ -61,11 +61,6 @@ public:
*/ */
bool Full() const { return records.size() >= buffer_size; } bool Full() const { return records.size() >= buffer_size; }
/**
* Clear the records buffer.
*/
void Clear() { records.clear(); }
private: private:
size_t buffer_size; size_t buffer_size;
std::vector<LogRecord> records; std::vector<LogRecord> records;
@ -269,9 +264,6 @@ protected:
// Buffer for bulk writes. // Buffer for bulk writes.
static const int WRITER_BUFFER_SIZE = 1000; static const int WRITER_BUFFER_SIZE = 1000;
detail::WriteBuffer write_buffer; // Buffer of size WRITER_BUFFER_SIZE. detail::WriteBuffer write_buffer; // Buffer of size WRITER_BUFFER_SIZE.
private:
void CleanupWriteBuffer();
}; };
} // namespace zeek::logging } // namespace zeek::logging