Most importantly fixed updating last_stat_size whenever cache is locked.
This now guarantees that it's always fully up-to-date when it's being
checked. Most of the other places updating last_stat_size are now
unnecessary, but I left them in case they'll be useful in the future.
Fixed also off-by-one where purging was done also when cache was exactly at
its maximum size.
i_assert(!MAIL_CACHE_IS_UNUSABLE(cache));
if (!ctx->tried_compression && ctx->cache_data != NULL &&
- cache->last_stat_size + ctx->cache_data->used >= cache_max_size) {
+ cache->last_stat_size + ctx->cache_data->used > cache_max_size) {
/* Looks like cache file is becoming too large. Try to compress
it to free up some space. */
if (cache->hdr->continued_record_count > 0 ||
mail_cache_set_syscall_error(cache, "stat()");
return TRUE;
}
+ cache->last_stat_size = st.st_size;
if (st.st_ino != cache->st_ino ||
!CMP_DEV_T(st.st_dev, cache->st_dev)) {