Skip to content

Commit

Permalink
Add traffic_server command line option for debugging in Au test.
Browse files Browse the repository at this point in the history
  • Loading branch information
ywkaras committed Apr 29, 2021
1 parent 8c98d99 commit b26fb37
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/traffic_server/traffic_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,19 @@ static int poll_timeout = -1; // No value set.
static int cmd_disable_freelist = 0;
static bool signal_received[NSIG];

/*
To be able to attach with a debugger to traffic_server running in an Au test case, temporarily change
the function call to create traffic_server to:
ts = Test.MakeATSProcess("ts", command="traffic_server --block")
ts.StartupTimeout = 60 * 60 * 10
This means Au test will wait effectively indefinitely (10 hours) for traffic_server to initialize itself.
Run the modified Au test, attach the debugger to the traffic_server process, set one or more breakpoints,
set the variable cmd_block to 0, then continue.
*/
static int cmd_block = 0;

// 1: the main thread delayed accepting, start accepting.
// 0: delay accept, wait for cache initialization.
// -1: cache is already initialized, don't delay.
Expand Down Expand Up @@ -217,6 +230,7 @@ static ArgumentDescription argument_descriptions[] = {
{"bind_stderr", '-', "Regular file to bind stderr to", "S512", &bind_stderr, "PROXY_BIND_STDERR", nullptr},
{"accept_mss", '-', "MSS for client connections", "I", &accept_mss, nullptr, nullptr},
{"poll_timeout", 't', "poll timeout in milliseconds", "I", &poll_timeout, nullptr, nullptr},
{"block", '-', "block for debug attach", "T", &cmd_block, nullptr, nullptr},
HELP_ARGUMENT_DESCRIPTION(),
VERSION_ARGUMENT_DESCRIPTION(),
RUNROOT_ARGUMENT_DESCRIPTION(),
Expand Down Expand Up @@ -1753,6 +1767,12 @@ main(int /* argc ATS_UNUSED */, const char **argv)
command_index = find_cmd_index(command_string);
command_valid = command_flag && command_index >= 0;

// Attach point when TS is blocked for debugging is in this loop.
//
while (cmd_block) {
sleep(1);
}

ink_freelist_init_ops(cmd_disable_freelist, cmd_disable_pfreelist);

#if TS_HAS_TESTS
Expand Down

0 comments on commit b26fb37

Please sign in to comment.