| 907 | #endif |
| 908 | |
| 909 | int |
| 910 | cmd_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 | |
| 954 | int |
| 955 | cmd_verify(char * /* cmd ATS_UNUSED */) |
nothing calls this directly
no test coverage detected