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
19 changes: 13 additions & 6 deletions proxy/logging/Log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ int Log::preproc_threads;
int Log::init_status = 0;
int Log::config_flags = 0;
bool Log::logging_mode_changed = false;
bool Log::log_rotate_signal_received = false;
uint32_t Log::periodic_tasks_interval = PERIODIC_TASKS_INTERVAL_FALLBACK;

// Hash table for LogField symbols
Expand Down Expand Up @@ -140,12 +141,6 @@ Log::change_configuration()
Debug("log-config", "... new configuration in place");
}

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

/*-------------------------------------------------------------------------
PERIODIC EVENTS

Expand Down Expand Up @@ -260,6 +255,10 @@ Log::periodic_tasks(long time_now)
}
Log::config->log_object_manager.roll_files(time_now);
}
if (log_rotate_signal_received) {
Log::config->log_object_manager.reopen_moved_log_files();
log_rotate_signal_received = false;
}
}
}

Expand Down Expand Up @@ -986,6 +985,14 @@ Log::handle_periodic_tasks_int_change(const char * /* name ATS_UNUSED */, RecDat
return REC_ERR_OKAY;
}

int
Log::handle_log_rotation_request()
{
Debug("log", "Request to reopen rotated log files.");
log_rotate_signal_received = true;
return 0;
}

void
Log::init(int flags)
{
Expand Down
8 changes: 5 additions & 3 deletions proxy/logging/Log.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,16 @@ class Log
// reconfiguration stuff
static void change_configuration();

static int handle_logging_mode_change(const char *name, RecDataT data_type, RecData data, void *cookie);
static int handle_periodic_tasks_int_change(const char *name, RecDataT data_type, RecData data, void *cookie);

/** Check each log file path to see whether it exists and re-open if not.
*
* This is called when an external log rotation entity has moved log files to
* rolled names. This checks whether the original log file exists and, if
* not, closes the file descriptor and re-opens the file.
*/
static void reopen_moved_log_files();
static int handle_logging_mode_change(const char *name, RecDataT data_type, RecData data, void *cookie);
static int handle_periodic_tasks_int_change(const char *name, RecDataT data_type, RecData data, void *cookie);
static int handle_log_rotation_request();

friend void RegressionTest_LogObjectManager_Transfer(RegressionTest *, int, int *);

Expand All @@ -226,6 +227,7 @@ class Log
static int init_status;
static int config_flags;
static bool logging_mode_changed;
static bool log_rotate_signal_received;
static uint32_t periodic_tasks_interval;
};

Expand Down
2 changes: 1 addition & 1 deletion src/traffic_server/traffic_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ class SignalContinuation : public Continuation
Note("Could not reseat %s", DIAGS_LOG_FILENAME);
}
// Reload any of the other moved log files (such as the ones in logging.yaml).
Log::reopen_moved_log_files();
Log::handle_log_rotation_request();
}

if (signal_received[SIGTERM] || signal_received[SIGINT]) {
Expand Down
1 change: 1 addition & 0 deletions tests/gold_tests/logging/sigusr2.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def __configure_traffic_manager(self):
'proxy.config.http.wait_for_cache': 1,
'proxy.config.diags.debug.enabled': 1,
'proxy.config.diags.debug.tags': 'log',
'proxy.config.log.periodic_tasks_interval': 1,

# All log rotation should be handled externally.
'proxy.config.log.rolling_enabled': 0,
Expand Down