mail-cache.c revision bba52ecbb0cfb6585f1a4ff29695dd2d27af98d2
5f5870385cff47efd2f58e7892f251cf13761528Timo Sirainen/* Copyright (c) 2003-2012 Dovecot authors, see the included COPYING file */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenvoid mail_cache_set_syscall_error(struct mail_cache *cache,
e8fd7988ec183fb6c104aed19a61f1a096c51d34Timo Sirainen mail_index_file_set_syscall_error(cache->index, cache->filepath,
6bc0f424bcdb9119d8159874cf98adfa53eefd9aTimo Sirainenstatic void mail_cache_unlink(struct mail_cache *cache)
d35fee8d1e5e31614dba5e64d45ed23c7d6bfa53Timo Sirainenvoid mail_cache_reset(struct mail_cache *cache)
ad850190d946d34966a56838cfdb216e021b5b5fTimo Sirainen /* mark the cache as unusable */
d35fee8d1e5e31614dba5e64d45ed23c7d6bfa53Timo Sirainenvoid mail_cache_set_corrupted(struct mail_cache *cache, const char *fmt, ...)
eddd9bf1a1369aea4a2715f6be1137da6d17d293Timo Sirainen "Corrupted index cache file %s: %s",
8aacc9e7c84f8376822823ec98c2f551d4919b2eTimo Sirainenvoid mail_cache_file_close(struct mail_cache *cache)
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen if (munmap(cache->mmap_base, cache->mmap_length) < 0)
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen mail_cache_set_syscall_error(cache, "munmap()");
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen mail_cache_set_syscall_error(cache, "close()");
abe7afb8f1766fbcef1b9df513109e43d7d16e49Timo Sirainenstatic void mail_cache_init_file_cache(struct mail_cache *cache)
abe7afb8f1766fbcef1b9df513109e43d7d16e49Timo Sirainen file_cache_set_fd(cache->file_cache, cache->fd);
abe7afb8f1766fbcef1b9df513109e43d7d16e49Timo Sirainen file_cache_set_size(cache->file_cache, st.st_size);
2131ef7a3390f15ea6a958256ea54908f1096350Timo Sirainen mail_cache_set_syscall_error(cache, "fstat()");
69e03a846f6980144aa75bff0590c04852bffbbcTimo Sirainenstatic bool mail_cache_need_reopen(struct mail_cache *cache)
69e03a846f6980144aa75bff0590c04852bffbbcTimo Sirainen /* we're waiting for compression */
69e03a846f6980144aa75bff0590c04852bffbbcTimo Sirainen /* disabled */
69e03a846f6980144aa75bff0590c04852bffbbcTimo Sirainen /* see if the file has changed */
66ecc94150cbce23aad3240135e0782e0a74d479Timo Sirainen if ((cache->index->flags & MAIL_INDEX_OPEN_FLAG_NFS_FLUSH) != 0) {
2131ef7a3390f15ea6a958256ea54908f1096350Timo Sirainen if (nfs_safe_stat(cache->filepath, &st) < 0) {
69e03a846f6980144aa75bff0590c04852bffbbcTimo Sirainen mail_cache_set_syscall_error(cache, "stat()");
bc564f1d3d953cf724828322b11ae89e0f59ffc9Timo Sirainen /* file changed */
66ecc94150cbce23aad3240135e0782e0a74d479Timo Sirainen if ((cache->index->flags & MAIL_INDEX_OPEN_FLAG_NFS_FLUSH) != 0) {
2131ef7a3390f15ea6a958256ea54908f1096350Timo Sirainen /* if the old file has been deleted, the new file may have
bc564f1d3d953cf724828322b11ae89e0f59ffc9Timo Sirainen the same inode as the old one. we'll catch this here by
bc564f1d3d953cf724828322b11ae89e0f59ffc9Timo Sirainen checking if fstat() fails with ESTALE */
bc564f1d3d953cf724828322b11ae89e0f59ffc9Timo Sirainen mail_cache_set_syscall_error(cache, "fstat()");
fd2f5fbc1f07aa93e2214a28cdf02437fb7d06c8Timo Sirainenint mail_cache_reopen(struct mail_cache *cache)
4b231ca0bbe3b536acbd350101e183441ce0247aTimo Sirainen /* reopening does no good */
fd2f5fbc1f07aa93e2214a28cdf02437fb7d06c8Timo Sirainen mail_cache_set_syscall_error(cache, "open()");
6a19e109ee8c5a6f688da83a86a7f6abeb71abddTimo Sirainen ext = mail_index_view_get_ext(view, cache->ext_id);
6a19e109ee8c5a6f688da83a86a7f6abeb71abddTimo Sirainen if (ext == NULL || cache->hdr->file_seq != ext->reset_id) {
fd2f5fbc1f07aa93e2214a28cdf02437fb7d06c8Timo Sirainen /* still different - maybe a race condition or maybe the
fd2f5fbc1f07aa93e2214a28cdf02437fb7d06c8Timo Sirainen file_seq really is corrupted. either way, this shouldn't
fd2f5fbc1f07aa93e2214a28cdf02437fb7d06c8Timo Sirainen happen often so we'll just mark cache to be compressed
fd2f5fbc1f07aa93e2214a28cdf02437fb7d06c8Timo Sirainen later which fixes this. */
58be9d6bcc3800f5b3d76a064ee767fbe31a5a8aTimo Sirainen cache->need_compress_file_seq = cache->hdr->file_seq;
25c22e54d1071d120641e9eecd0023e7373e65ffTimo Sirainenstatic void mail_cache_update_need_compress(struct mail_cache *cache)
25c22e54d1071d120641e9eecd0023e7373e65ffTimo Sirainen const struct mail_cache_header *hdr = cache->hdr;
25c22e54d1071d120641e9eecd0023e7373e65ffTimo Sirainen cont_percentage = hdr->continued_record_count * 100 /
25c22e54d1071d120641e9eecd0023e7373e65ffTimo Sirainen (cache->index->map->rec_map->records_count == 0 ? 1 :
25c22e54d1071d120641e9eecd0023e7373e65ffTimo Sirainen if (cont_percentage >= MAIL_CACHE_COMPRESS_CONTINUED_PERCENTAGE &&
25c22e54d1071d120641e9eecd0023e7373e65ffTimo Sirainen hdr->used_file_size >= MAIL_CACHE_COMPRESS_MIN_SIZE) {
25c22e54d1071d120641e9eecd0023e7373e65ffTimo Sirainen /* too many continued rows, compress */
25c22e54d1071d120641e9eecd0023e7373e65ffTimo Sirainen cache->need_compress_file_seq = hdr->file_seq;
25c22e54d1071d120641e9eecd0023e7373e65ffTimo Sirainen /* see if we've reached the max. deleted space in file */
25c22e54d1071d120641e9eecd0023e7373e65ffTimo Sirainen hdr->used_file_size >= MAIL_CACHE_COMPRESS_MIN_SIZE)
25c22e54d1071d120641e9eecd0023e7373e65ffTimo Sirainen cache->need_compress_file_seq = hdr->file_seq;
8ac66221e8fdc2c5523cff1893e0d1c5de25fa49Timo Sirainenstatic bool mail_cache_verify_header(struct mail_cache *cache,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen /* check that the header is still ok */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen if (cache->mmap_length < sizeof(struct mail_cache_header)) {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen mail_cache_set_corrupted(cache, "File too small");
a40d26f83af808a0ea1e212c001d682a96d870b0Timo Sirainen /* version changed - upgrade silently */
e192a3b1ca8ae857e7d87298ea507d32977ba570Timo Sirainen if (hdr->compat_sizeof_uoff_t != sizeof(uoff_t)) {
e192a3b1ca8ae857e7d87298ea507d32977ba570Timo Sirainen /* architecture change - handle silently(?) */
c4877db8b6559846f4b58be8e42422dc734c193fTimo Sirainen /* index id changed - handle silently */
8b9342aa96b2f297e23afb261f9f7dd859800952Timo Sirainen mail_cache_set_corrupted(cache, "file_seq is 0");
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen /* only check the header if we're locked */
a40d26f83af808a0ea1e212c001d682a96d870b0Timo Sirainen if (hdr->used_file_size < sizeof(struct mail_cache_header)) {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen mail_cache_set_corrupted(cache, "used_file_size too small");
a40d26f83af808a0ea1e212c001d682a96d870b0Timo Sirainen if ((hdr->used_file_size % sizeof(uint32_t)) != 0) {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen mail_cache_set_corrupted(cache, "used_file_size not aligned");
56f45b3f3ae20e5c933701f4657dda5ef1916855Timo Sirainen mail_cache_set_corrupted(cache, "used_file_size too large");
18d92dbbb752c79dc461514e52f7ef11847e636bTimo Sirainenmail_cache_map_finish(struct mail_cache *cache, uoff_t offset, size_t size,
f81801789c71f64a2fc3c44d09f9864bbc68cd45Timo Sirainen const struct mail_cache_header *hdr = hdr_data;
f81801789c71f64a2fc3c44d09f9864bbc68cd45Timo Sirainen /* verify the header validity only with offset=0. this way
f81801789c71f64a2fc3c44d09f9864bbc68cd45Timo Sirainen we won't waste time re-verifying it all the time */
18d92dbbb752c79dc461514e52f7ef11847e636bTimo Sirainenmail_cache_map_with_read(struct mail_cache *cache, size_t offset, size_t size,
18d92dbbb752c79dc461514e52f7ef11847e636bTimo Sirainen const void **data_r)
18d92dbbb752c79dc461514e52f7ef11847e636bTimo Sirainen cache->read_offset + cache->read_buf->used >= offset+size) {
18d92dbbb752c79dc461514e52f7ef11847e636bTimo Sirainen /* already mapped */
bb86f8f22f2561438ce710d2113f04a4d0082b50Timo Sirainen *data_r = CONST_PTR_OFFSET(cache->read_buf->data,
f81801789c71f64a2fc3c44d09f9864bbc68cd45Timo Sirainen return mail_cache_map_finish(cache, offset, size, hdr_data, TRUE);
ab1e5b156d1b5480d36ed6e8e06197339d803038Timo Sirainen if (offset == 0 && size < MAIL_CACHE_MIN_HEADER_READ_SIZE) {
ab1e5b156d1b5480d36ed6e8e06197339d803038Timo Sirainen /* we can usually read the fields header after the cache
ab1e5b156d1b5480d36ed6e8e06197339d803038Timo Sirainen header. we need them both, so try to read them all with one
ab1e5b156d1b5480d36ed6e8e06197339d803038Timo Sirainen pread() call. */
18d92dbbb752c79dc461514e52f7ef11847e636bTimo Sirainen data = buffer_append_space_unsafe(cache->read_buf, size);
18d92dbbb752c79dc461514e52f7ef11847e636bTimo Sirainen mail_cache_set_syscall_error(cache, "read()");
f81801789c71f64a2fc3c44d09f9864bbc68cd45Timo Sirainen return mail_cache_map_finish(cache, offset, size, hdr_data, TRUE);
82ed69779f49bd71ef1b570ce8aca67d357dbee8Timo Sirainenint mail_cache_map(struct mail_cache *cache, size_t offset, size_t size,
82ed69779f49bd71ef1b570ce8aca67d357dbee8Timo Sirainen const void **data_r)
18d92dbbb752c79dc461514e52f7ef11847e636bTimo Sirainen return mail_cache_map_with_read(cache, offset, size, data_r);
1098fc409a45e7603701dc94635927a673bee0c1Timo Sirainen ret = file_cache_read(cache->file_cache, offset, size);
1e47cfede3a0b62654105daab00e97b5d660bc6bTimo Sirainen /* In case of ESTALE we'll simply fail without error
1e47cfede3a0b62654105daab00e97b5d660bc6bTimo Sirainen messages. The caller will then just have to
1e47cfede3a0b62654105daab00e97b5d660bc6bTimo Sirainen fallback to generating the value itself.
1e47cfede3a0b62654105daab00e97b5d660bc6bTimo Sirainen We can't simply reopen the cache flie, because
1e47cfede3a0b62654105daab00e97b5d660bc6bTimo Sirainen using it requires also having updated file
1e47cfede3a0b62654105daab00e97b5d660bc6bTimo Sirainen mail_cache_set_syscall_error(cache, "read()");
18d92dbbb752c79dc461514e52f7ef11847e636bTimo Sirainen *data_r = offset > cache->mmap_length ? NULL :
f81801789c71f64a2fc3c44d09f9864bbc68cd45Timo Sirainen return mail_cache_map_finish(cache, offset, size, data, TRUE);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen /* already mapped */
82ed69779f49bd71ef1b570ce8aca67d357dbee8Timo Sirainen *data_r = CONST_PTR_OFFSET(cache->mmap_base, offset);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen if (munmap(cache->mmap_base, cache->mmap_length) < 0)
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen mail_cache_set_syscall_error(cache, "munmap()");
4b231ca0bbe3b536acbd350101e183441ce0247aTimo Sirainen /* unusable, waiting for compression or
4b231ca0bbe3b536acbd350101e183441ce0247aTimo Sirainen index is in memory */
58be9d6bcc3800f5b3d76a064ee767fbe31a5a8aTimo Sirainen i_assert(cache->need_compress_file_seq != 0 ||
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen /* map the whole file */
72cbf33ae81fde08384d30c779ff540752d9256cTimo Sirainen cache->mmap_base = mmap_ro_file(cache->fd, &cache->mmap_length);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen mail_cache_set_syscall_error(cache, "mmap()");
18d92dbbb752c79dc461514e52f7ef11847e636bTimo Sirainen *data_r = offset > cache->mmap_length ? NULL :
f81801789c71f64a2fc3c44d09f9864bbc68cd45Timo Sirainen return mail_cache_map_finish(cache, offset, size,
6a8a4c9f530668cd8961b73d702856ed94f05f80Timo Sirainenstatic int mail_cache_try_open(struct mail_cache *cache)
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen mail_cache_set_syscall_error(cache, "open()");
82ed69779f49bd71ef1b570ce8aca67d357dbee8Timo Sirainen if (mail_cache_map(cache, 0, sizeof(struct mail_cache_header),
6a8a4c9f530668cd8961b73d702856ed94f05f80Timo Sirainenint mail_cache_open_and_verify(struct mail_cache *cache)
6a8a4c9f530668cd8961b73d702856ed94f05f80Timo Sirainen /* failed for some reason - doesn't really matter,
6a8a4c9f530668cd8961b73d702856ed94f05f80Timo Sirainen it's disabled for now. */
f239eb76f77afcbc0bfc97c9b52b4407d1bc3fe6Timo Sirainenstatic struct mail_cache *mail_cache_alloc(struct mail_index *index)
a835194f9a9dae88528367a791cbc282589f6c01Timo Sirainen i_strconcat(index->filepath, MAIL_CACHE_FILE_SUFFIX, NULL);
0b878c6a17c608fcd8b52a5762ed2c6a5cf4700aTimo Sirainen cache->field_pool = pool_alloconly_create("Cache fields", 2048);
3ccab0bac68040f179a7de45c516cec258e28fdbTimo Sirainen hash_table_create(default_pool, cache->field_pool, 0,
3ccab0bac68040f179a7de45c516cec258e28fdbTimo Sirainen strcase_hash, (hash_cmp_callback_t *)strcasecmp);
66ecc94150cbce23aad3240135e0782e0a74d479Timo Sirainen (index->flags & MAIL_INDEX_OPEN_FLAG_DOTLOCK_USE_EXCL) != 0;
66ecc94150cbce23aad3240135e0782e0a74d479Timo Sirainen (index->flags & MAIL_INDEX_OPEN_FLAG_NFS_FLUSH) != 0;
036626b19f14bef582f96e556913ae91b1d67881Timo Sirainen I_MIN(MAIL_CACHE_LOCK_TIMEOUT, index->max_lock_timeout_secs);
13c6532dc104d23061e6901783ceb1ff8872c206Timo Sirainen cache->dotlock_settings.stale_timeout = MAIL_CACHE_LOCK_CHANGE_TIMEOUT;
66ecc94150cbce23aad3240135e0782e0a74d479Timo Sirainen (index->flags & MAIL_INDEX_OPEN_FLAG_MMAP_DISABLE) != 0)
18d92dbbb752c79dc461514e52f7ef11847e636bTimo Sirainen (cache->index->flags & MAIL_INDEX_OPEN_FLAG_SAVEONLY) != 0;
59151b71059df1190acd75d8717ed04a7920c862Timo Sirainen mail_index_register_expunge_handler(index, cache->ext_id, FALSE,
6a19e109ee8c5a6f688da83a86a7f6abeb71abddTimo Sirainen mail_index_register_sync_handler(index, cache->ext_id,
f239eb76f77afcbc0bfc97c9b52b4407d1bc3fe6Timo Sirainenstruct mail_cache *mail_cache_open_or_create(struct mail_index *index)
f239eb76f77afcbc0bfc97c9b52b4407d1bc3fe6Timo Sirainenstruct mail_cache *mail_cache_create(struct mail_index *index)
5196f9ea42d02000f9c3d22f20aa816140af4422Timo Sirainen if (unlink(cache->filepath) < 0 && errno != ENOENT)
5196f9ea42d02000f9c3d22f20aa816140af4422Timo Sirainen mail_cache_set_syscall_error(cache, "unlink()");
d5cebe7f98e63d4e2822863ef2faa4971e8b3a5dTimo Sirainenvoid mail_cache_free(struct mail_cache **_cache)
519e0a461271843833a2b42626ad93f6e7ddc497Timo Sirainen mail_index_unregister_sync_lost_handler(cache->index,
519e0a461271843833a2b42626ad93f6e7ddc497Timo Sirainen mail_index_unregister_expunge_handler(cache->index, cache->ext_id);
519e0a461271843833a2b42626ad93f6e7ddc497Timo Sirainen mail_index_unregister_sync_handler(cache->index, cache->ext_id);
d0bbbc7057aa33b52ee378196dee7d773437468fTimo Sirainenstatic int mail_cache_lock_file(struct mail_cache *cache, bool nonblock)
763f83d3cc47bce05cbc396419c4db2b71dd8e68Timo Sirainen /* previous locking failed. don't waste time waiting on it
763f83d3cc47bce05cbc396419c4db2b71dd8e68Timo Sirainen again, just try once to see if it's available now. */
d9fdacd5fb3e07997e5c389739d2054f0c8441d8Timo Sirainen if (cache->index->lock_method != FILE_LOCK_METHOD_DOTLOCK) {
51b979b6414b940f04677a7e2d064be119345954Timo Sirainen ret = mail_index_lock_fd(cache->index, cache->filepath,
51b979b6414b940f04677a7e2d064be119345954Timo Sirainen ret = file_dotlock_create(&cache->dotlock_settings,
5bdad39213d28ab35e615a7f4ea1712ab25b6a80Timo Sirainen "file_dotlock_create()");
4aae8acbcfa9cac96b4af39bfabcbe569e804827Timo Sirainen /* don't bother warning if locking failed due to a timeout. since cache
4aae8acbcfa9cac96b4af39bfabcbe569e804827Timo Sirainen updating isn't all that important we're using a very short timeout
4aae8acbcfa9cac96b4af39bfabcbe569e804827Timo Sirainen so it can be triggered sometimes on heavy load */
bc564f1d3d953cf724828322b11ae89e0f59ffc9Timo Sirainen mail_index_flush_read_cache(cache->index, cache->filepath, cache->fd,
d9fdacd5fb3e07997e5c389739d2054f0c8441d8Timo Sirainenstatic void mail_cache_unlock_file(struct mail_cache *cache)
d9fdacd5fb3e07997e5c389739d2054f0c8441d8Timo Sirainen if (cache->index->lock_method != FILE_LOCK_METHOD_DOTLOCK)
d0bbbc7057aa33b52ee378196dee7d773437468fTimo Sirainenmail_cache_lock_full(struct mail_cache *cache, bool require_same_reset_id,
df6478c4cf605bd81b3891c148b84c14eb6c4035Timo Sirainen ext = mail_index_view_get_ext(iview, cache->ext_id);
6a19e109ee8c5a6f688da83a86a7f6abeb71abddTimo Sirainen /* cache not used */
fd2f5fbc1f07aa93e2214a28cdf02437fb7d06c8Timo Sirainen for (i = 0; i < 3; i++) {
cf3bea6d9b57f8608bec22d98ad547a507b05f66Timo Sirainen /* we want the latest cache file */
dc0474dc9d5652d76cb41f439844dd80c8b96642Timo Sirainen /* either we're still waiting for index to
dc0474dc9d5652d76cb41f439844dd80c8b96642Timo Sirainen catch up with a cache compression, or
dc0474dc9d5652d76cb41f439844dd80c8b96642Timo Sirainen that catching up is never going to happen */
e6e43b396799aa5704c679a3017d6c7195f9347dTimo Sirainen if (ret < 0 || (ret == 0 && require_same_reset_id))
d0bbbc7057aa33b52ee378196dee7d773437468fTimo Sirainen if ((ret = mail_cache_lock_file(cache, nonblock)) <= 0) {
fd2f5fbc1f07aa93e2214a28cdf02437fb7d06c8Timo Sirainen /* okay, so it was just compressed. try again. */
1098fc409a45e7603701dc94635927a673bee0c1Timo Sirainen /* make sure our header is up to date */
114a0f74e0f825c6bd8aeadfafb248a030762a1fTimo Sirainen sizeof(struct mail_cache_header));
6fdf8b5e4e71a69f5974f59eec2b8c19bc421fe2Timo Sirainen i_assert((ret <= 0 && !cache->locked) || (ret > 0 && cache->locked));
d0bbbc7057aa33b52ee378196dee7d773437468fTimo Sirainenint mail_cache_lock(struct mail_cache *cache, bool require_same_reset_id)
d0bbbc7057aa33b52ee378196dee7d773437468fTimo Sirainen return mail_cache_lock_full(cache, require_same_reset_id, FALSE);
d0bbbc7057aa33b52ee378196dee7d773437468fTimo Sirainenint mail_cache_try_lock(struct mail_cache *cache)
d0bbbc7057aa33b52ee378196dee7d773437468fTimo Sirainen return mail_cache_lock_full(cache, FALSE, TRUE);
a817fdcc43aedf423e2134091d5f83f91d64bcc9Timo Sirainenint mail_cache_unlock(struct mail_cache *cache)
62cfc346eb7b0a4fd9e1ab6edd63b98711161229Timo Sirainen /* we found it to be broken during the lock. just clean up. */
b780aa272b742a43579cdb523cc79cc8d4521306Timo Sirainen if (cache->index->fsync_mode == FSYNC_MODE_ALWAYS) {
51b979b6414b940f04677a7e2d064be119345954Timo Sirainen mail_cache_set_syscall_error(cache, "fdatasync()");
dbd9604da561399cc6255289d5b6f6f662ab2d00Timo Sirainenint mail_cache_write(struct mail_cache *cache, const void *data, size_t size,
dbd9604da561399cc6255289d5b6f6f662ab2d00Timo Sirainen if (pwrite_full(cache->fd, data, size, offset) < 0) {
dbd9604da561399cc6255289d5b6f6f662ab2d00Timo Sirainen mail_cache_set_syscall_error(cache, "pwrite_full()");
dbd9604da561399cc6255289d5b6f6f662ab2d00Timo Sirainen file_cache_write(cache->file_cache, data, size, offset);
f3976df875193529127d584cb713983e8160bdcfTimo Sirainenbool mail_cache_exists(struct mail_cache *cache)
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenmail_cache_view_open(struct mail_cache *cache, struct mail_index_view *iview)
128ea07dab8d67124ea74bcc085a478784b6358aTimo Sirainenvoid mail_cache_view_close(struct mail_cache_view **_view)
5724e7103eed12fe36b55a7b5a8653284a2184b9Timo Sirainen if (view->cache->field_header_write_pending &&
4bbee99b3aef449a9a2a11a5b5cf1ca486915c49Timo Sirainen (void)mail_cache_header_fields_update(view->cache);
8fa86f7ef06aa6cf0239c7ca2eb98889691d40d4Timo Sirainenvoid mail_cache_view_update_cache_decisions(struct mail_cache_view *view,
956f7778e413d3184d69e7b96e4a6b3cd5570bcdTimo Sirainenuint32_t mail_cache_get_first_new_seq(struct mail_index_view *view)
956f7778e413d3184d69e7b96e4a6b3cd5570bcdTimo Sirainen if (!mail_index_lookup_seq_range(view, idx_hdr->day_first_uid[7],
956f7778e413d3184d69e7b96e4a6b3cd5570bcdTimo Sirainen /* all messages are too old */