]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
gc: reformat source code to conform to Linux codestyle
authorPetr Špaček <petr.spacek@nic.cz>
Wed, 10 Jul 2019 13:30:51 +0000 (15:30 +0200)
committerPetr Špaček <petr.spacek@nic.cz>
Wed, 10 Jul 2019 13:59:24 +0000 (15:59 +0200)
Main motivation is getting rid of tab-space mix.
Reformated using github/torvalds/linux/master/scripts/Lindent.

utils/cache_gc/categories.c
utils/cache_gc/categories.h
utils/cache_gc/db.c
utils/cache_gc/db.h
utils/cache_gc/kr_cache_gc.c
utils/cache_gc/kr_cache_gc.h
utils/cache_gc/main.c

index 2e49baf1893a17ce20d807dbe3fa717d3db0fe6a..a3a25ca8ee2542daee36f7199c05133a39a53d54 100644 (file)
@@ -25,7 +25,7 @@ static int get_random(int to)
 }
 
 // TODO this is just an example, make this more clever
-category_t kr_gc_categorize(gc_record_info_t *info)
+category_t kr_gc_categorize(gc_record_info_t * info)
 {
        category_t res;
 
@@ -33,13 +33,13 @@ category_t kr_gc_categorize(gc_record_info_t *info)
                return CATEGORIES - 1;
 
        switch (info->no_labels) {
-       case 0: /* root zone */
+       case 0:         /* root zone */
                res = 5;
                break;
-       case 1: /* TLD */
+       case 1:         /* TLD */
                res = 10;
                break;
-       default: /* SLD and below */
+       default:                /* SLD and below */
                res = (rrtype_is_infrastructure(info->rrtype) ? 15 : 20);
                if (info->entry_size > 300)
                        /* Penalty for big answers */
@@ -53,4 +53,3 @@ category_t kr_gc_categorize(gc_record_info_t *info)
 
        return res + get_random(5);
 }
-
index e6e91371c7008f54eab8ec0209738e58d890e545..12c5a6adcd91d01ea92c2a8b1304ab721bb1fb0a 100644 (file)
@@ -4,7 +4,6 @@
 
 typedef uint8_t category_t;
 
-#define CATEGORIES 100 // number of categories
-
-category_t kr_gc_categorize(gc_record_info_t *info);
+#define CATEGORIES 100         // number of categories
 
+category_t kr_gc_categorize(gc_record_info_t * info);
index 6c68e35748ed51f9331f4731cb787d8899b86ad8..bb6b6185a5fee6b427008facca3b37e28d839e3c 100644 (file)
@@ -5,29 +5,27 @@
 #include <lib/cache/impl.h>
 //#include <lib/defines.h>
 
-#include <ctype.h> //DEBUG
+#include <ctype.h>             //DEBUG
 #include <time.h>
 #include <sys/stat.h>
 
-struct libknot_lmdb_env
-{
+struct libknot_lmdb_env {
        bool shared;
        unsigned dbi;
        void *env;
        knot_mm_t *pool;
 };
 
-struct kres_lmdb_env
-{
+struct kres_lmdb_env {
        size_t mapsize;
        unsigned dbi;
        void *env;
        // sub-struct txn ommited
 };
 
-static knot_db_t *knot_db_t_kres2libknot(const knot_db_t *db)
+static knot_db_t *knot_db_t_kres2libknot(const knot_db_t * db)
 {
-       const struct kres_lmdb_env *kres_db = db; // this is struct lmdb_env as in resolver/cdb_lmdb.c
+       const struct kres_lmdb_env *kres_db = db;       // this is struct lmdb_env as in resolver/cdb_lmdb.c
        struct libknot_lmdb_env *libknot_db = malloc(sizeof(*libknot_db));
        if (libknot_db != NULL) {
                libknot_db->shared = false;
@@ -38,13 +36,15 @@ static knot_db_t *knot_db_t_kres2libknot(const knot_db_t *db)
        return libknot_db;
 }
 
-int kr_gc_cache_open(const char *cache_path, struct kr_cache *kres_db, knot_db_t **libknot_db)
+int kr_gc_cache_open(const char *cache_path, struct kr_cache *kres_db,
+                    knot_db_t ** libknot_db)
 {
        char cache_data[strlen(cache_path) + 10];
        snprintf(cache_data, sizeof(cache_data), "%s/data.mdb", cache_path);
 
        struct stat st = { 0 };
-       if (stat(cache_path, &st) || !(st.st_mode & S_IFDIR) || stat(cache_data, &st)) {
+       if (stat(cache_path, &st) || !(st.st_mode & S_IFDIR)
+           || stat(cache_data, &st)) {
                printf("Error: %s does not exist or is not a LMDB.\n", cache_path);
                return -ENOENT;
        }
@@ -68,7 +68,7 @@ int kr_gc_cache_open(const char *cache_path, struct kr_cache *kres_db, knot_db_t
        return 0;
 }
 
-void kr_gc_cache_close(struct kr_cache *kres_db, knot_db_t *knot_db)
+void kr_gc_cache_close(struct kr_cache *kres_db, knot_db_t * knot_db)
 {
        free(knot_db);
        kr_cache_close(kres_db);
@@ -82,15 +82,15 @@ const uint16_t *kr_gc_key_consistent(knot_db_val_t key)
        ssize_t i;
        /* CACHE_KEY_DEF */
        if (key.len >= 2 && kd[0] == '\0') {
-                /* Beware: root zone is special and starts with
+               /* Beware: root zone is special and starts with
                 *         a single \0 followed by type sign */
-                i = 1;
+               i = 1;
        } else {
                /* find the first double zero in the key */
-                for (i = 2; kd[i - 1] || kd[i - 2]; ++i) {
-                    if (i >= key.len)
-                           return NULL;
-                }
+               for (i = 2; kd[i - 1] || kd[i - 2]; ++i) {
+                       if (i >= key.len)
+                               return NULL;
+               }
        }
        // the next character can be used for classification
        switch (kd[i]) {
@@ -99,7 +99,7 @@ const uint16_t *kr_gc_key_consistent(knot_db_val_t key)
                        assert(!EINVAL);
                        return NULL;
                }
-               return (uint16_t *)&kd[i + 1];
+               return (uint16_t *) & kd[i + 1];
        case '1':
                return &NSEC1;
        case '3':
@@ -110,12 +110,12 @@ const uint16_t *kr_gc_key_consistent(knot_db_val_t key)
 }
 
 /// expects that key is consistent! CACHE_KEY_DEF
-static uint8_t entry_labels(knot_db_val_t *key, uint16_t rrtype)
+static uint8_t entry_labels(knot_db_val_t * key, uint16_t rrtype)
 {
        uint8_t lab = 0, *p = key->data;
        while (*p != 0) {
                while (*p++ != 0) {
-                       if (p - (uint8_t *)key->data >= key->len) {
+                       if (p - (uint8_t *) key->data >= key->len) {
                                return 0;
                        }
                }
@@ -131,7 +131,8 @@ static uint8_t entry_labels(knot_db_val_t *key, uint16_t rrtype)
 }
 
 #ifdef DEBUG
-void debug_printbin(const char *str, unsigned int len) {
+void debug_printbin(const char *str, unsigned int len)
+{
        putchar('"');
        for (int idx = 0; idx < len; idx++) {
                char c = str[idx];
@@ -145,7 +146,7 @@ void debug_printbin(const char *str, unsigned int len) {
 #endif
 
 /** Return one entry_h reference from a cache DB value.  NULL if not consistent/suitable. */
-static const struct entry_h * val2entry(const knot_db_val_t val, uint16_t ktype)
+static const struct entry_h *val2entry(const knot_db_val_t val, uint16_t ktype)
 {
        if (ktype != KNOT_RRTYPE_NS)
                return entry_h_consistent(val, ktype);
@@ -163,7 +164,7 @@ static const struct entry_h * val2entry(const knot_db_val_t val, uint16_t ktype)
        return NULL;
 }
 
-int kr_gc_cache_iter(knot_db_t *knot_db, kr_gc_iter_callback callback, void *ctx)
+int kr_gc_cache_iter(knot_db_t * knot_db, kr_gc_iter_callback callback, void *ctx)
 {
 #ifdef DEBUG
        unsigned int counter_iter = 0;
@@ -206,7 +207,8 @@ int kr_gc_cache_iter(knot_db_t *knot_db, kr_gc_iter_callback callback, void *ctx
 
                info.entry_size = key.len + val.len;
                info.valid = false;
-               const uint16_t *entry_type = ret == KNOT_EOK ? kr_gc_key_consistent(key) : NULL;
+               const uint16_t *entry_type =
+                   ret == KNOT_EOK ? kr_gc_key_consistent(key) : NULL;
                const struct entry_h *entry = NULL;
                if (entry_type != NULL) {
 #ifdef DEBUG
@@ -227,10 +229,11 @@ int kr_gc_cache_iter(knot_db_t *knot_db, kr_gc_iter_callback callback, void *ctx
                }
 #ifdef DEBUG
                counter_kr_consistent += info.valid;
-               if (!entry_type || !entry) { // don't log fully consistent entries
-                       printf("GC %sconsistent, KR %sconsistent, size %zu, key len %zu: ",
-                               entry_type ? "" : "in", entry ? "" : "IN",
-                               (key.len + val.len), key.len);
+               if (!entry_type || !entry) {    // don't log fully consistent entries
+                       printf
+                           ("GC %sconsistent, KR %sconsistent, size %zu, key len %zu: ",
+                            entry_type ? "" : "in", entry ? "" : "IN",
+                            (key.len + val.len), key.len);
                        debug_printbin(key.data, key.len);
                        printf("\n");
                }
@@ -238,7 +241,8 @@ int kr_gc_cache_iter(knot_db_t *knot_db, kr_gc_iter_callback callback, void *ctx
                ret = callback(&key, &info, ctx);
 
                if (ret != KNOT_EOK) {
-                       printf("Error iterating database (%s).\n", knot_strerror(ret));
+                       printf("Error iterating database (%s).\n",
+                              knot_strerror(ret));
                        api->iter_finish(it);
                        api->txn_abort(&txn);
                        return ret;
@@ -250,7 +254,8 @@ skip:
 
        api->txn_abort(&txn);
 #ifdef DEBUG
-       printf("DEBUG: iterated %u items, gc consistent %u, kr consistent %u\n", counter_iter, counter_gc_consistent, counter_kr_consistent);
+       printf("DEBUG: iterated %u items, gc consistent %u, kr consistent %u\n",
+              counter_iter, counter_gc_consistent, counter_kr_consistent);
 #endif
        return KNOT_EOK;
 }
index 52a7ee36e470e07eeb998100a3868fe65d6ec802..91566313886d14fb47aad37c92754651bf0d86e5 100644 (file)
@@ -5,12 +5,14 @@
 
 #include "kr_cache_gc.h"
 
-int kr_gc_cache_open(const char *cache_path, struct kr_cache *kres_db, knot_db_t **libknot_db);
+int kr_gc_cache_open(const char *cache_path, struct kr_cache *kres_db,
+                    knot_db_t ** libknot_db);
 
-void kr_gc_cache_close(struct kr_cache *kres_db, knot_db_t *knot_db);
+void kr_gc_cache_close(struct kr_cache *kres_db, knot_db_t * knot_db);
 
-typedef int (*kr_gc_iter_callback)(const knot_db_val_t *key, gc_record_info_t *info, void *ctx);
+typedef int (*kr_gc_iter_callback)(const knot_db_val_t * key,
+                                  gc_record_info_t * info, void *ctx);
 
-int kr_gc_cache_iter(knot_db_t *knot_db, kr_gc_iter_callback callback, void *ctx);
+int kr_gc_cache_iter(knot_db_t * knot_db, kr_gc_iter_callback callback, void *ctx);
 
 const uint16_t *kr_gc_key_consistent(knot_db_val_t key);
index b06dd80d4ac81488547ad615e2f22897afed08d5..519f8bb94debcc704f0708d14c4108a3055dbf32 100644 (file)
 typedef struct timespec gc_timer_t;
 static gc_timer_t gc_timer_internal = { 0 };
 
-static void gc_timer_start(gc_timer_t *t)
+static void gc_timer_start(gc_timer_t * t)
 {
        (void)clock_gettime(CLOCK_MONOTONIC, t == NULL ? &gc_timer_internal : t);
 }
 
-static double gc_timer_end(gc_timer_t *t)
+static double gc_timer_end(gc_timer_t * t)
 {
        gc_timer_t *start = t == NULL ? &gc_timer_internal : t;
        gc_timer_t end = { 0 };
        (void)clock_gettime(CLOCK_MONOTONIC, &end);
-       return (((double)end.tv_sec - (double)start->tv_sec) + ((double)end.tv_nsec - (double)start->tv_nsec) / 1e9);
+       return (((double)end.tv_sec - (double)start->tv_sec) +
+               ((double)end.tv_nsec - (double)start->tv_nsec) / 1e9);
 }
 
-static unsigned long gc_timer_usecs(gc_timer_t *t)
+static unsigned long gc_timer_usecs(gc_timer_t * t)
 {
        gc_timer_t *start = t == NULL ? &gc_timer_internal : t;
        gc_timer_t end = { 0 };
        (void)clock_gettime(CLOCK_MONOTONIC, &end);
-       return ((end.tv_sec - start->tv_sec) * 1000000UL + (end.tv_nsec - start->tv_nsec) / 1000UL);
+       return ((end.tv_sec - start->tv_sec) * 1000000UL +
+               (end.tv_nsec - start->tv_nsec) / 1000UL);
 }
 
 // section: dbval_copy
 
-static knot_db_val_t *dbval_copy(const knot_db_val_t *from)
+static knot_db_val_t *dbval_copy(const knot_db_val_t * from)
 {
        knot_db_val_t *to = malloc(sizeof(knot_db_val_t) + from->len);
        if (to != NULL) {
                memcpy(to, from, sizeof(knot_db_val_t));
-               to->data = to + 1; // == ((uit8_t *)to) + sizeof(knot_db_val_t)
+               to->data = to + 1;      // == ((uit8_t *)to) + sizeof(knot_db_val_t)
                memcpy(to->data, from->data, from->len);
        }
        return to;
@@ -61,9 +63,8 @@ static knot_db_val_t *dbval_copy(const knot_db_val_t *from)
 // section: rrtype list
 
 dynarray_declare(rrtype, uint16_t, DYNARRAY_VISIBILITY_STATIC, 64)
-dynarray_define(rrtype, uint16_t, DYNARRAY_VISIBILITY_STATIC)
-
-static void rrtypelist_add(rrtype_dynarray_t *arr, uint16_t add_type)
+    dynarray_define(rrtype, uint16_t, DYNARRAY_VISIBILITY_STATIC)
+static void rrtypelist_add(rrtype_dynarray_t * arr, uint16_t add_type)
 {
        bool already_present = false;
        dynarray_foreach(rrtype, uint16_t, i, *arr) {
@@ -77,7 +78,7 @@ static void rrtypelist_add(rrtype_dynarray_t *arr, uint16_t add_type)
        }
 }
 
-static void rrtypelist_print(rrtype_dynarray_t *arr)
+static void rrtypelist_print(rrtype_dynarray_t * arr)
 {
        char type_s[32] = { 0 };
        dynarray_foreach(rrtype, uint16_t, i, *arr) {
@@ -87,11 +88,11 @@ static void rrtypelist_print(rrtype_dynarray_t *arr)
        printf("\n");
 }
 
-dynarray_declare(entry, knot_db_val_t*, DYNARRAY_VISIBILITY_STATIC, 256)
-dynarray_define(entry, knot_db_val_t*, DYNARRAY_VISIBILITY_STATIC)
-static void entry_dynarray_deep_free(entry_dynarray_t *d)
+dynarray_declare(entry, knot_db_val_t *, DYNARRAY_VISIBILITY_STATIC, 256)
+    dynarray_define(entry, knot_db_val_t *, DYNARRAY_VISIBILITY_STATIC)
+static void entry_dynarray_deep_free(entry_dynarray_t * d)
 {
-       dynarray_foreach(entry, knot_db_val_t*, i, *d) {
+       dynarray_foreach(entry, knot_db_val_t *, i, *d) {
                free(*i);
        }
        entry_dynarray_free(d);
@@ -102,7 +103,8 @@ typedef struct {
        size_t records;
 } ctx_compute_categories_t;
 
-int cb_compute_categories(const knot_db_val_t *key, gc_record_info_t *info, void *vctx)
+int cb_compute_categories(const knot_db_val_t * key, gc_record_info_t * info,
+                         void *vctx)
 {
        ctx_compute_categories_t *ctx = vctx;
        category_t cat = kr_gc_categorize(info);
@@ -120,7 +122,8 @@ typedef struct {
        size_t oversize_records;
 } ctx_delete_categories_t;
 
-int cb_delete_categories(const knot_db_val_t *key, gc_record_info_t *info, void *vctx)
+int cb_delete_categories(const knot_db_val_t * key, gc_record_info_t * info,
+                        void *vctx)
 {
        ctx_delete_categories_t *ctx = vctx;
        category_t cat = kr_gc_categorize(info);
@@ -128,8 +131,7 @@ int cb_delete_categories(const knot_db_val_t *key, gc_record_info_t *info, void
                knot_db_val_t *todelete = dbval_copy(key);
                size_t used = ctx->used_space + key->len + sizeof(*key);
                if ((ctx->cfg_temp_keys_space > 0 &&
-                    used > ctx->cfg_temp_keys_space) ||
-                   todelete == NULL) {
+                    used > ctx->cfg_temp_keys_space) || todelete == NULL) {
                        ctx->oversize_records++;
                } else {
                        entry_dynarray_add(&ctx->to_delete, &todelete);
@@ -139,7 +141,7 @@ int cb_delete_categories(const knot_db_val_t *key, gc_record_info_t *info, void
        return KNOT_EOK;
 }
 
-int kr_cache_gc(kr_cache_gc_cfg_t *cfg)
+int kr_cache_gc(kr_cache_gc_cfg_t * cfg)
 {
        struct kr_cache kres_db = { 0 };
        knot_db_t *db = NULL;
@@ -152,7 +154,7 @@ int kr_cache_gc(kr_cache_gc_cfg_t *cfg)
        const size_t db_size = knot_db_lmdb_get_mapsize(db);
        const size_t db_usage_abs = knot_db_lmdb_get_usage(db);
        const double db_usage = (double)db_usage_abs / db_size * 100.0;
-#if 0 // Probably not worth it, better reduce the risk by checking more often.
+#if 0                          // Probably not worth it, better reduce the risk by checking more often.
        if (db_usage > 90.0) {
                free(*libknot_db);
                kr_cache_close(kres_db);
@@ -160,20 +162,23 @@ int kr_cache_gc(kr_cache_gc_cfg_t *cfg)
                opts.maxsize = cache_size;
                goto open_kr_cache;
        }
-# endif
+#endif
        const bool large_usage = db_usage >= cfg->cache_max_usage;
-       if (cfg->dry_run || large_usage) { // don't print this on every size check
-               printf("Usage: %.2lf%% (%zu / %zu)\n", db_usage, db_usage_abs, db_size);
+       if (cfg->dry_run || large_usage) {      // don't print this on every size check
+               printf("Usage: %.2lf%% (%zu / %zu)\n", db_usage, db_usage_abs,
+                      db_size);
        }
        if (cfg->dry_run || !large_usage) {
                kr_gc_cache_close(&kres_db, db);
                return KNOT_EOK;
        }
 
-       gc_timer_t timer_analyze = { 0 }, timer_choose = { 0 }, timer_delete = { 0 }, timer_rw_txn = { 0 };
+       gc_timer_t timer_analyze = { 0 }, timer_choose = { 0 }, timer_delete =
+           { 0 }, timer_rw_txn = { 0 };
 
        gc_timer_start(&timer_analyze);
-       ctx_compute_categories_t cats = {{ 0 }};
+       ctx_compute_categories_t cats = { { 0 }
+       };
        ret = kr_gc_cache_iter(db, cb_compute_categories, &cats);
        if (ret != KNOT_EOK) {
                kr_gc_cache_close(&kres_db, db);
@@ -189,13 +194,14 @@ int kr_cache_gc(kr_cache_gc_cfg_t *cfg)
                cats_sumsize += cats.categories_sizes[i];
        }
        ssize_t amount_tofree = knot_db_lmdb_get_mapsize(db) * cfg->cache_to_be_freed
-               * cats_sumsize / (100 * knot_db_lmdb_get_usage(db));
+           * cats_sumsize / (100 * knot_db_lmdb_get_usage(db));
 
 #ifdef DEBUG
        printf("tofree: %zd\n", amount_tofree);
        for (int i = 0; i < CATEGORIES; i++) {
                if (cats.categories_sizes[i] > 0) {
-                       printf("category %d size %zu\n", i, cats.categories_sizes[i]);
+                       printf("category %d size %zu\n", i,
+                              cats.categories_sizes[i]);
                }
        }
 #endif
@@ -205,7 +211,8 @@ int kr_cache_gc(kr_cache_gc_cfg_t *cfg)
                amount_tofree -= cats.categories_sizes[--limit_category];
        }
 
-       printf("Cache analyzed in %.2lf secs, %zu records, limit category is %d.\n", gc_timer_end(&timer_analyze), cats.records, limit_category);
+       printf("Cache analyzed in %.2lf secs, %zu records, limit category is %d.\n",
+              gc_timer_end(&timer_analyze), cats.records, limit_category);
 
        gc_timer_start(&timer_choose);
        ctx_delete_categories_t to_del = { 0 };
@@ -217,8 +224,10 @@ int kr_cache_gc(kr_cache_gc_cfg_t *cfg)
                kr_gc_cache_close(&kres_db, db);
                return ret;
        }
-       printf("%zu records to be deleted using %.2lf MBytes of temporary memory, %zu records skipped due to memory limit.\n",
-              to_del.to_delete.size, ((double)to_del.used_space / 1048576.0), to_del.oversize_records);
+       printf
+           ("%zu records to be deleted using %.2lf MBytes of temporary memory, %zu records skipped due to memory limit.\n",
+            to_del.to_delete.size, ((double)to_del.used_space / 1048576.0),
+            to_del.oversize_records);
 
        const knot_db_api_t *api = knot_db_lmdb_api();
        knot_db_txn_t txn = { 0 };
@@ -230,13 +239,14 @@ int kr_cache_gc(kr_cache_gc_cfg_t *cfg)
 
        ret = api->txn_begin(db, &txn, 0);
        if (ret != KNOT_EOK) {
-               printf("Error starting R/W DB transaction (%s).\n", knot_strerror(ret));
+               printf("Error starting R/W DB transaction (%s).\n",
+                      knot_strerror(ret));
                entry_dynarray_deep_free(&to_del.to_delete);
                kr_gc_cache_close(&kres_db, db);
                return ret;
        }
 
-       dynarray_foreach(entry, knot_db_val_t*, i, to_del.to_delete) {
+       dynarray_foreach(entry, knot_db_val_t *, i, to_del.to_delete) {
                ret = api->del(&txn, *i);
                switch (ret) {
                case KNOT_EOK:
@@ -249,11 +259,14 @@ int kr_cache_gc(kr_cache_gc_cfg_t *cfg)
                        already_gone++;
                        break;
                default:
-                       printf("Warning: skipping deletion because of error (%s)\n", knot_strerror(ret));
+                       printf("Warning: skipping deletion because of error (%s)\n",
+                              knot_strerror(ret));
                        api->txn_abort(&txn);
                        ret = api->txn_begin(db, &txn, 0);
                        if (ret != KNOT_EOK) {
-                               printf("Error: can't begin txn because of error (%s)\n", knot_strerror(ret));
+                               printf
+                                   ("Error: can't begin txn because of error (%s)\n",
+                                    knot_strerror(ret));
                                goto finish;
                        }
                        continue;
@@ -270,7 +283,8 @@ int kr_cache_gc(kr_cache_gc_cfg_t *cfg)
                                ret = api->txn_begin(db, &txn, 0);
                        }
                        if (ret != KNOT_EOK) {
-                               printf("Error: transaction failed (%s)\n", knot_strerror(ret));
+                               printf("Error: transaction failed (%s)\n",
+                                      knot_strerror(ret));
                                goto finish;
                        }
                }
@@ -278,9 +292,11 @@ int kr_cache_gc(kr_cache_gc_cfg_t *cfg)
        ret = api->txn_commit(&txn);
 
 finish:
-       printf("Deleted %zu records (%zu already gone) types", deleted_records, already_gone);
+       printf("Deleted %zu records (%zu already gone) types", deleted_records,
+              already_gone);
        rrtypelist_print(&deleted_rrtypes);
-       printf("It took %.2lf secs, %zu transactions (%s)\n", gc_timer_end(&timer_delete), rw_txn_count, knot_strerror(ret));
+       printf("It took %.2lf secs, %zu transactions (%s)\n",
+              gc_timer_end(&timer_delete), rw_txn_count, knot_strerror(ret));
 
        rrtype_dynarray_free(&deleted_rrtypes);
        entry_dynarray_deep_free(&to_del.to_delete);
index bebc2bcc6446c9a948bbc54ffa1c3549a9f3c65c..c0ca0ccc1409f2dd6fbe205c11ad68bac6769aa4 100644 (file)
@@ -5,31 +5,30 @@
 #include <stdint.h>
 
 typedef struct {
-        size_t entry_size;          // amount of bytes occupied in cache by this record
-        bool valid;                 // fields further down are valid (ignore them if false)
-        int64_t expires_in;         // < 0 => already expired
-        uint16_t rrtype;
-        uint8_t no_labels;          // 0 == ., 1 == root zone member, 2 == TLD member ...
-        uint8_t rank;
+       size_t entry_size;      // amount of bytes occupied in cache by this record
+       bool valid;             // fields further down are valid (ignore them if false)
+       int64_t expires_in;     // < 0 => already expired
+       uint16_t rrtype;
+       uint8_t no_labels;      // 0 == ., 1 == root zone member, 2 == TLD member ...
+       uint8_t rank;
 } gc_record_info_t;
 
 typedef struct {
-        const char *cache_path;          // path to the LMDB with resolver cache
-        unsigned long gc_interval;       // waiting time between two whole garbage collections in usecs (0 = just one-time cleanup)
+       const char *cache_path; // path to the LMDB with resolver cache
+       unsigned long gc_interval;      // waiting time between two whole garbage collections in usecs (0 = just one-time cleanup)
 
-        size_t temp_keys_space;          // maximum amount of temporary memory for copied keys in bytes (0 = unlimited)
+       size_t temp_keys_space; // maximum amount of temporary memory for copied keys in bytes (0 = unlimited)
 
-        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
+       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
 
-         uint8_t cache_max_usage;         // maximum cache usage before triggering GC (percent)
-         uint8_t cache_to_be_freed;       // percent of cache to be freed during GC
+       uint8_t cache_max_usage;        // maximum cache usage before triggering GC (percent)
+       uint8_t cache_to_be_freed;      // percent of cache to be freed during GC
 
-        bool dry_run;
+       bool dry_run;
 } kr_cache_gc_cfg_t;
 
-
-int kr_cache_gc(kr_cache_gc_cfg_t *cfg);
+int kr_cache_gc(kr_cache_gc_cfg_t * cfg);
 
 #define KR_CACHE_GC_VERSION "0.2"
index 29285e87c1b181c1d2d6e8412440fcf03394c600..fad4ef6a46108f8b81055214db0888fc7466a031 100644 (file)
@@ -128,4 +128,3 @@ int main(int argc, char *argv[])
 
        return 0;
 }
-