From: Libor Peltan Date: Fri, 11 May 2018 14:20:28 +0000 (+0200) Subject: kr_cache_gc: implemented dry-run (only occupation watching mode) X-Git-Tag: v4.1.0^2~36 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1541953abf31e9104772a7bf6b230e3e2cc338b5;p=thirdparty%2Fknot-resolver.git kr_cache_gc: implemented dry-run (only occupation watching mode) --- diff --git a/utils/kr_cache_gc/kr_cache_gc.c b/utils/kr_cache_gc/kr_cache_gc.c index 773c8a6da..14985ac99 100644 --- a/utils/kr_cache_gc/kr_cache_gc.c +++ b/utils/kr_cache_gc/kr_cache_gc.c @@ -153,7 +153,7 @@ int kr_cache_gc(kr_cache_gc_cfg_t *cfg) return ret; } - if (db_usage < MAX_OK_PERCENT_USAGE) { + if (cfg->dry_run || db_usage < MAX_OK_PERCENT_USAGE) { kr_gc_cache_close(&kres_db, db); return KNOT_EOK; } diff --git a/utils/kr_cache_gc/kr_cache_gc.h b/utils/kr_cache_gc/kr_cache_gc.h index 8031131e7..fc1806b91 100644 --- a/utils/kr_cache_gc/kr_cache_gc.h +++ b/utils/kr_cache_gc/kr_cache_gc.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include @@ -20,6 +21,8 @@ typedef struct { size_t rw_txn_items; // maximum number of deleted records per RW transaction (0 = unlimited) unsigned long rw_txn_duration; // maximum duration of RW transaction in usecs (0 = unlimited) unsigned long rw_txn_delay; // waiting time between two RW transactions in usecs + + bool dry_run; } kr_cache_gc_cfg_t; diff --git a/utils/kr_cache_gc/main.c b/utils/kr_cache_gc/main.c index 7ef03a43e..a154386a0 100644 --- a/utils/kr_cache_gc/main.c +++ b/utils/kr_cache_gc/main.c @@ -35,6 +35,7 @@ static void print_help() printf(" -m \n"); printf(" -w \n"); printf(" -t \n"); + printf(" -n (= dry run)\n"); } int main(int argc, char *argv[]) @@ -50,7 +51,7 @@ int main(int argc, char *argv[]) kr_cache_gc_cfg_t cfg = { 0 }; int o; - while ((o = getopt(argc, argv, "hc:d:l:m:w:t:")) != -1) { + while ((o = getopt(argc, argv, "hnc:d:l:m:w:t:")) != -1) { switch (o) { case 'c': cfg.cache_path = optarg; @@ -74,6 +75,9 @@ int main(int argc, char *argv[]) cfg.temp_keys_space *= 1048576; break; #undef get_nonneg_optarg + case 'n': + cfg.dry_run = true; + break; case ':': case '?': case 'h':