Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/proxy/logging/Log.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ class Log
static int va_error(const char *format, va_list ap);
static int error(const char *format, ...) TS_PRINTFLIKE(1, 2);

static void flush_all_objects();

// public data members
static LogObject *error_log;
/** The latest fully initialized LogConfig.
Expand Down
25 changes: 19 additions & 6 deletions src/proxy/logging/Log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1325,6 +1325,14 @@ Log::va_error(const char *format, va_list ap)
return ret_val;
}

void
Log::flush_all_objects()
{
if (config) {
config->log_object_manager.flush_all_objects();
}
}

/*-------------------------------------------------------------------------
Log::preproc_thread_main

Expand All @@ -1343,9 +1351,6 @@ Log::preproc_thread_main(void *args)
Log::preproc_notify[idx].lock();

while (true) {
if (TSSystemState::is_event_system_shut_down()) {
return nullptr;
}
LogConfig *current = static_cast<LogConfig *>(configProcessor.get(log_configid));

if (likely(current)) {
Expand All @@ -1360,6 +1365,13 @@ Log::preproc_thread_main(void *args)
configProcessor.release(log_configid, current);
}

// Drain any remaining buffers before exiting on shutdown.
if (TSSystemState::is_event_system_shut_down()) {
// Signal flush thread to drain data we just pushed.
Log::flush_notify->signal();
return nullptr;
}

// wait for more work; a spurious wake-up is ok since we'll just
// check the queue and find there is nothing to do, then wait
// again.
Expand All @@ -1384,9 +1396,6 @@ Log::flush_thread_main(void * /* args ATS_UNUSED */)
Log::flush_notify->lock();

while (true) {
if (TSSystemState::is_event_system_shut_down()) {
return nullptr;
}
fdata = static_cast<LogFlushData *>(ink_atomiclist_popall(flush_data_list));

// invert the list
Expand Down Expand Up @@ -1478,6 +1487,10 @@ Log::flush_thread_main(void * /* args ATS_UNUSED */)
// check the queue and find there is nothing to do, then wait
// again.
//
if (TSSystemState::is_event_system_shut_down()) {
return nullptr;
}

Log::flush_notify->wait();
}

Expand Down
8 changes: 8 additions & 0 deletions src/traffic_server/traffic_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,15 @@ struct AutoStopCont : public Continuation {
jsonrpcServer->stop_thread();
}

// Push buffered log entries into the preproc queue before shutdown.
Log::flush_all_objects();

TSSystemState::shut_down_event_system();

// Wake preproc threads to drain remaining log buffers before exit.
for (int i = 0; i < Log::preproc_threads; i++) {
Log::preproc_notify[i].signal();
}
delete this;
return EVENT_CONT;
}
Expand Down