]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Add mail_cache_map_all()
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 30 Mar 2020 14:17:11 +0000 (17:17 +0300)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Wed, 15 Apr 2020 08:57:20 +0000 (08:57 +0000)
src/lib-index/mail-cache-private.h
src/lib-index/mail-cache.c

index 70d9ca82ee4801e520806ea8b330ffff7d8307d8..b757490d842031e09776ecc1d36482d80ae18c61 100644 (file)
@@ -244,8 +244,12 @@ mail_cache_transaction_lookup_rec(struct mail_cache_transaction_ctx *ctx,
                                  unsigned int seq,
                                  unsigned int *trans_next_idx);
 
+/* Return data from the specified position in the cache file. Returns 1 if
+   successful, 0 if offset/size points outside the cache file, -1 if error. */
 int mail_cache_map(struct mail_cache *cache, size_t offset, size_t size,
                   const void **data_r);
+/* Map the whole cache file into memory. Returns 0 if ok, -1 if error. */
+int mail_cache_map_all(struct mail_cache *cache);
 void mail_cache_file_close(struct mail_cache *cache);
 int mail_cache_reopen(struct mail_cache *cache);
 
index 0e464143a2bc8385c10a8c35de969091333297f9..81e2b7b5c4150c37e5baebf8a2a9c97b9c73e999 100644 (file)
@@ -520,6 +520,15 @@ int mail_cache_map(struct mail_cache *cache, size_t offset, size_t size,
                                     cache->mmap_base, FALSE);
 }
 
+int mail_cache_map_all(struct mail_cache *cache)
+{
+       const void *data;
+
+       int ret = mail_cache_map(cache, 0, 0, &data);
+       i_assert(ret != 0);
+       return ret < 0 ? -1 : 0;
+}
+
 int mail_cache_open_and_verify(struct mail_cache *cache)
 {
        int ret;