Copilot commented on code in PR #13328:
URL: https://github.com/apache/trafficserver/pull/13328#discussion_r3702682650
##########
src/traffic_ctl/traffic_ctl.cc:
##########
@@ -315,6 +317,20 @@ main([[maybe_unused]] int argc, const char **argv)
.add_option("--params", "-p", "Parameters to be passed in the request,
YAML or JSON format", "", MORE_THAN_ONE_ARG_N, "", "")
.add_example_usage("traffic_ctl rpc invoke foo_bar -p \"numbers: [1, 2,
3]\"");
+ // cache shm commands - operate directly on POSIX shared memory; no running
server required.
+ auto &shm_command = cache_command.add_command("shm", "Inspect and manage
cache shared-memory segments").require_commands();
+ // No parser-level default for --prefix: ArgParser injects defaults into the
parsed
+ // arguments, which would make an omitted --prefix indistinguishable from an
explicit
+ // one. CacheShmCommand supplies the runtime default and keys its "did you
set
+ // name_prefix?" hint off the option being absent.
+ shm_command.add_option("--prefix", "-p", "shm name prefix word, framed as
/<word>- (default 'ats')", "", 1, "");
+ shm_command.add_command("status", "Show the cache shared-memory control
segment and stripe table", [&]() { command->execute(); })
+ .add_example_usage("traffic_ctl cache shm status")
+ .add_example_usage("traffic_ctl cache shm status --prefix ats-t");
+ shm_command.add_command("clear", "Unlink the cache shared-memory control and
stripe segments", [&]() { command->execute(); })
+ .add_example_usage("traffic_ctl cache shm clear")
+ .add_example_usage("traffic_ctl cache shm clear --prefix ats-t");
Review Comment:
The `status`/`clear` subcommands are wired to lambdas that call
`command->execute()`, which risks dereferencing an unset `command` (or
bypassing the normal command-construction path) depending on how `ArgParser`
triggers callbacks. To avoid ordering/initialization hazards and match the
other leaf commands in this file, wire these subcommands through the same
execution callback mechanism used elsewhere (e.g., `Command_Execute`), letting
the factory create `CacheShmCommand` from the parsed args before execution.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]