]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-dict: Add dict_expire_scan()
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 14 Jun 2022 09:25:39 +0000 (12:25 +0300)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Wed, 15 Jun 2022 20:24:42 +0000 (20:24 +0000)
src/lib-dict/dict-private.h
src/lib-dict/dict.c
src/lib-dict/dict.h

index 727ba631aa03274dfc1bd3ff04d8dfe0ced27ec7..89bd4b7c0b46550d37bce249e994ba66a5a92018 100644 (file)
@@ -17,6 +17,7 @@ struct dict_vfuncs {
                    struct dict **dict_r, const char **error_r);
        void (*deinit)(struct dict *dict);
        void (*wait)(struct dict *dict);
+       int (*expire_scan)(struct dict *dict, const char **error_r);
 
        int (*lookup)(struct dict *dict, const struct dict_op_settings *set,
                      pool_t pool, const char *key, const char *const **values_r,
index 20ba9e6392d605467637bb2004d13938cf692dab..9e8531bdaaac5ac902ea1bc554365215794dead9 100644 (file)
@@ -204,6 +204,14 @@ bool dict_switch_ioloop(struct dict *dict)
        return ret;
 }
 
+int dict_expire_scan(struct dict *dict, const char **error_r)
+{
+       if (dict->v.expire_scan == NULL)
+               return 0;
+       else
+               return dict->v.expire_scan(dict, error_r);
+}
+
 static bool dict_key_prefix_is_valid(const char *key, const char *username)
 {
        if (str_begins_with(key, DICT_PATH_SHARED))
index 4e029fb1891ca6dad38b4169766b46d96a654308..4d56b8748fdeea9b90fc10470dd562f61f9c9341 100644 (file)
@@ -110,6 +110,12 @@ bool dict_have_async_operations(struct dict *dict);
    be waited on. */
 bool dict_switch_ioloop(struct dict *dict) ATTR_NOWARN_UNUSED_RESULT;
 
+/* Scan the dict for expired entries and delete them. Returns 0 if dict does
+   not support expire scanning (and there is no need to call this function
+   again), 1 if expire scanning was run successfully, -1 if expire scanning
+   failed. */
+int dict_expire_scan(struct dict *dict, const char **error_r);
+
 /* Lookup the first value for the key. Set it to NULL if it's not found.
    Returns 1 if found, 0 if not found and -1 if lookup failed. */
 int dict_lookup(struct dict *dict, const struct dict_op_settings *set, pool_t pool,