MCPcopy Create free account
hub / github.com/apache/trafficserver / cmd_clear

Function cmd_clear

src/traffic_server/traffic_server.cc:909–952  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

907#endif
908
909int
910cmd_clear(char *cmd)
911{
912 Note("CLEAR");
913
914 bool c_all = !strcmp(cmd, "clear");
915 bool c_hdb = !strcmp(cmd, "clear_hostdb");
916 bool c_cache = !strcmp(cmd, "clear_cache");
917
918 if (c_all || c_hdb) {
919 std::string rundir(RecConfigReadRuntimeDir());
920 std::string config(Layout::relative_to(rundir, "hostdb.config"));
921
922 Note("Clearing HostDB Configuration");
923 if (unlink(config.c_str()) < 0) {
924 Note("unable to unlink %s", config.c_str());
925 }
926 }
927
928 if (c_hdb || c_all) {
929 Note("Clearing Host Database");
930 if (hostDBProcessor.cache()->start(PROCESSOR_RECONFIGURE) < 0) {
931 Note("unable to open Host Database, CLEAR failed");
932 return CMD_FAILED;
933 }
934 hostDBProcessor.cache()->refcountcache->clear();
935 if (c_hdb) {
936 return CMD_OK;
937 }
938 }
939
940 if (c_all || c_cache) {
941 Note("Clearing Cache");
942
943 cacheProcessor.afterInitCallbackSet(&CB_cmd_cache_clear);
944 if (cacheProcessor.start_internal(PROCESSOR_RECONFIGURE) < 0) {
945 Note("unable to open Cache, CLEAR failed");
946 return CMD_FAILED;
947 }
948 return CMD_IN_PROGRESS;
949 }
950
951 return CMD_OK;
952}
953
954int
955cmd_verify(char * /* cmd ATS_UNUSED */)

Callers

nothing calls this directly

Calls 8

strcmpFunction · 0.85
RecConfigReadRuntimeDirFunction · 0.85
afterInitCallbackSetMethod · 0.80
start_internalMethod · 0.80
c_strMethod · 0.45
startMethod · 0.45
cacheMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected