]> git.ipfire.org Git - thirdparty/dovecot/core.git/log
thirdparty/dovecot/core.git
5 years agolib-http: http-server-request - Provide default response for OPTIONS * request.
Stephan Bosch [Sun, 17 Nov 2019 13:28:37 +0000 (14:28 +0100)] 
lib-http: http-server-request - Provide default response for OPTIONS * request.

5 years agolib-http: http-server-connection - Run request callback in new datastack frame.
Stephan Bosch [Sun, 17 Nov 2019 09:52:52 +0000 (10:52 +0100)] 
lib-http: http-server-connection - Run request callback in new datastack frame.

5 years agolib-http: http-server-connection - Restructure request callback handling.
Stephan Bosch [Fri, 8 Nov 2019 16:11:36 +0000 (17:11 +0100)] 
lib-http: http-server-connection - Restructure request callback handling.

Move most of it to http-server-request.

5 years agolib-http: server: Replace http_*_debug() with e_debug().
Stephan Bosch [Fri, 8 Nov 2019 16:11:35 +0000 (17:11 +0100)] 
lib-http: server: Replace http_*_debug() with e_debug().

5 years agolib-http: server: Replace http_*_error() with e_error().
Stephan Bosch [Fri, 8 Nov 2019 16:11:34 +0000 (17:11 +0100)] 
lib-http: server: Replace http_*_error() with e_error().

5 years agolib-http: server: Replace i_error() with e_error().
Stephan Bosch [Fri, 8 Nov 2019 16:11:32 +0000 (17:11 +0100)] 
lib-http: server: Replace i_error() with e_error().

5 years agolib-http: server: Remove redundant debug logging checks.
Stephan Bosch [Fri, 8 Nov 2019 16:11:32 +0000 (17:11 +0100)] 
lib-http: server: Remove redundant debug logging checks.

5 years agolib-http: server: Add support for event API.
Stephan Bosch [Fri, 8 Nov 2019 16:11:31 +0000 (17:11 +0100)] 
lib-http: server: Add support for event API.

5 years agolib-http: http-server-request - Make http_server_request_label() a normal function.
Stephan Bosch [Mon, 11 Nov 2019 16:20:48 +0000 (17:20 +0100)] 
lib-http: http-server-request - Make http_server_request_label() a normal function.

5 years agolib-http: Reformat http-server-response.c.
Stephan Bosch [Sat, 9 Nov 2019 08:36:56 +0000 (09:36 +0100)] 
lib-http: Reformat http-server-response.c.

5 years agolib-http: Reformat http-server-request.c.
Stephan Bosch [Fri, 8 Nov 2019 16:11:31 +0000 (17:11 +0100)] 
lib-http: Reformat http-server-request.c.

5 years agolib-http: Reformat http-server-connection.c.
Stephan Bosch [Fri, 8 Nov 2019 16:11:30 +0000 (17:11 +0100)] 
lib-http: Reformat http-server-connection.c.

5 years agolib-http: Reformat http-server-private.h.
Stephan Bosch [Fri, 8 Nov 2019 16:11:29 +0000 (17:11 +0100)] 
lib-http: Reformat http-server-private.h.

5 years agolib-http: Reformat http-server.h.
Stephan Bosch [Fri, 8 Nov 2019 16:11:28 +0000 (17:11 +0100)] 
lib-http: Reformat http-server.h.

5 years agoAdd generated dovecot.service file to .gitignore.
Stephan Bosch [Fri, 17 Apr 2020 14:35:19 +0000 (16:35 +0200)] 
Add generated dovecot.service file to .gitignore.

5 years agolib-index: Fix cache purging when index is being rebuilt
Timo Sirainen [Thu, 16 Apr 2020 12:59:24 +0000 (15:59 +0300)] 
lib-index: Fix cache purging when index is being rebuilt

All the messages until trans->first_new_seq no longer exist after reset.
At best they cause confusion and are ignored. They could also point to
high UIDs that the rebuilding removes, causing further corruption errors.

5 years agolib-storage: index_index_rebuild_init() - Assert-crash if index isn't locked
Timo Sirainen [Thu, 16 Apr 2020 11:46:28 +0000 (14:46 +0300)] 
lib-storage: index_index_rebuild_init() - Assert-crash if index isn't locked

5 years agolib-index: Add mail_index_lock_sync() and mail_index_unlock()
Timo Sirainen [Thu, 16 Apr 2020 11:46:03 +0000 (14:46 +0300)] 
lib-index: Add mail_index_lock_sync() and mail_index_unlock()

5 years agoauth: Implement auth-worker-client per-command events.
Juha-Petri Tyrkkö [Mon, 30 Mar 2020 06:48:32 +0000 (09:48 +0300)] 
auth: Implement auth-worker-client per-command events.

5 years agolib-index: When flushing cache changes to disk, try to also write offsets to transact...
Timo Sirainen [Wed, 1 Apr 2020 19:53:55 +0000 (22:53 +0300)] 
lib-index: When flushing cache changes to disk, try to also write offsets to transaction log

This works as long as there aren't any newly created non-committed mails.

5 years agolib-index: Cache purging shouldn't always change YES decisions to TEMP
Timo Sirainen [Sun, 5 Apr 2020 15:36:44 +0000 (18:36 +0300)] 
lib-index: Cache purging shouldn't always change YES decisions to TEMP

Previously every purging changed YES decision to be changed to TEMP.
This behaved rather badly if a cache file was purged twice within short
time period, because the clients might not have had time to access the
mailbox and change the decision back to YES. That in turn could have
dropped old mails' cached fields even though the client might still want
to use them. (A workaround for this has been to list all useful fields in
mail_always_cache_fields setting.)

The new behavior is to update the last_used field for a YES decision only
when the YES decision has been confirmed. If it's not confirmed for 30
days (mail_cache_unaccessed_field_drop) then its decision is changed to
TEMP on the next purge.

The new behavior also doubles the time when unaccessed field is dropped
from 30 days to 60 days (2*mail_cache_unaccessed_field_drop). This is
needed so that the field isn't dropped too early after YES -> TEMP
decision is changed.

5 years agolib-index: Split off mail_cache_purge_check_field()
Timo Sirainen [Sun, 5 Apr 2020 15:27:17 +0000 (18:27 +0300)] 
lib-index: Split off mail_cache_purge_check_field()

5 years agolib-index: mail_cache_decision_state_update() - Minor refactoring
Timo Sirainen [Sun, 5 Apr 2020 15:09:18 +0000 (18:09 +0300)] 
lib-index: mail_cache_decision_state_update() - Minor refactoring

Simplifies the next commit.

5 years agolib-index: Split off mail_cache_update_last_used()
Timo Sirainen [Sun, 5 Apr 2020 15:10:24 +0000 (18:10 +0300)] 
lib-index: Split off mail_cache_update_last_used()

5 years agolib-oauth2: Fix linking unit tests
Timo Sirainen [Wed, 15 Apr 2020 12:16:24 +0000 (15:16 +0300)] 
lib-oauth2: Fix linking unit tests

Reverses 0b3b67b848d7032ae94b14b3317ff0b6a45a4057, which was wrong because
lib-http requires lib-master. Also libmaster now requires linking with
lib-auth.

5 years agoauth: Fix potential timing attack in verying crypt() results
Timo Sirainen [Wed, 25 Mar 2020 08:48:13 +0000 (10:48 +0200)] 
auth: Fix potential timing attack in verying crypt() results

Probably impractical attack in any case, but lets do this just to be extra
safe.

5 years agolib-imap-urlauth: Fix potential timing attack in verifying the token
Timo Sirainen [Wed, 25 Mar 2020 08:43:33 +0000 (10:43 +0200)] 
lib-imap-urlauth: Fix potential timing attack in verifying the token

5 years agoauth: DOVECOT-TOKEN mechanism - Fix potential timing attack in verying the token
Timo Sirainen [Wed, 25 Mar 2020 08:42:40 +0000 (10:42 +0200)] 
auth: DOVECOT-TOKEN mechanism - Fix potential timing attack in verying the token

5 years agolib: Add str_equals_timing_almost_safe()
Timo Sirainen [Tue, 7 Apr 2020 16:16:10 +0000 (19:16 +0300)] 
lib: Add str_equals_timing_almost_safe()

5 years agolib-storage: Initialize new cache hdr.* fields with NO decision
Timo Sirainen [Sun, 5 Apr 2020 20:30:41 +0000 (23:30 +0300)] 
lib-storage: Initialize new cache hdr.* fields with NO decision

Calling mail_cache_add() afterwards will change their decision to TEMP.
Or if it's not called, it probably wasn't wanted to be cached anyway.
Most importantly this change will cause mail_cache_decision event to be
triggered for these newly cached headers.

5 years agolib-storage: When sorting mails, mark all the sort program fields as "wanted"
Timo Sirainen [Mon, 6 Apr 2020 11:34:42 +0000 (14:34 +0300)] 
lib-storage: When sorting mails, mark all the sort program fields as "wanted"

Usually only the first field in the sort program is used, so this likely
doesn't make a big difference.

Also, this was already done in a different way for all header fields in the
program. However, the next commit will remove that way.

5 years agolib-index: Add test-mail-cache unit test
Timo Sirainen [Tue, 31 Mar 2020 19:23:05 +0000 (22:23 +0300)] 
lib-index: Add test-mail-cache unit test

5 years agolib-index: Add test-mail-cache-purge unit test
Timo Sirainen [Tue, 31 Mar 2020 18:45:38 +0000 (21:45 +0300)] 
lib-index: Add test-mail-cache-purge unit test

5 years agolib-index: mailbox_cache_purge*() - Add reason string
Timo Sirainen [Fri, 3 Apr 2020 08:06:15 +0000 (11:06 +0300)] 
lib-index: mailbox_cache_purge*() - Add reason string

Include the reason in the mail_cache_purge_* events also.

5 years agolib-index: Add mail_cache_record_corrupted event
Timo Sirainen [Thu, 2 Apr 2020 21:22:45 +0000 (00:22 +0300)] 
lib-index: Add mail_cache_record_corrupted event

5 years agolib-index: Add mail_cache_corrupted event
Timo Sirainen [Thu, 2 Apr 2020 20:52:46 +0000 (23:52 +0300)] 
lib-index: Add mail_cache_corrupted event

5 years agolib-index: If major_version or uoff_t size change in cache file, log error
Timo Sirainen [Thu, 2 Apr 2020 21:18:28 +0000 (00:18 +0300)] 
lib-index: If major_version or uoff_t size change in cache file, log error

These events really aren't expected, so it's better to clearly log errors
about them rather than silently delete the cache file.

5 years agolib-index: Merge mail_cache_reset() into mail_cache_unlink()
Timo Sirainen [Thu, 2 Apr 2020 20:48:50 +0000 (23:48 +0300)] 
lib-index: Merge mail_cache_reset() into mail_cache_unlink()

There are no external callers to mail_cache_reset(), and this simplifies the
code.

5 years agolib-index: mail_cache_set_seq_corrupted_reason() - Don't delete entire cache if trans...
Timo Sirainen [Thu, 2 Apr 2020 21:07:23 +0000 (00:07 +0300)] 
lib-index: mail_cache_set_seq_corrupted_reason() - Don't delete entire cache if transaction commit fails

It can only happen on I/O errors, which most likely means that there's no
disk space to write to transaction log. There's no reason to delete the
entire cache, since it might be expensive to recreate.

5 years agolib-index: Add mail_cache_decision_changed event
Timo Sirainen [Thu, 2 Apr 2020 20:45:49 +0000 (23:45 +0300)] 
lib-index: Add mail_cache_decision_changed event

5 years agolib-index: Add mail_cache_purge_drop_field event
Timo Sirainen [Thu, 2 Apr 2020 20:38:23 +0000 (23:38 +0300)] 
lib-index: Add mail_cache_purge_drop_field event

5 years agolib-index: Add mail_cache_purge_started/finished events
Timo Sirainen [Thu, 2 Apr 2020 20:12:00 +0000 (23:12 +0300)] 
lib-index: Add mail_cache_purge_started/finished events

5 years agolib-index: Log a warning if cache purging causes changes to be lost
Timo Sirainen [Tue, 31 Mar 2020 12:21:28 +0000 (15:21 +0300)] 
lib-index: Log a warning if cache purging causes changes to be lost

5 years agolib-index: Add mail_cache.event with a log prefix and mail-cache category
Timo Sirainen [Thu, 2 Apr 2020 20:25:59 +0000 (23:25 +0300)] 
lib-index: Add mail_cache.event with a log prefix and mail-cache category

5 years agolib-index: Rename "index" event category to "mail-index"
Timo Sirainen [Sat, 4 Apr 2020 09:44:02 +0000 (12:44 +0300)] 
lib-index: Rename "index" event category to "mail-index"

It's a bit too ambiguous to call it just "index" since we have so many
different ones.

5 years agolib-storage: Use mailbox.event as parent to mail_index
Timo Sirainen [Thu, 2 Apr 2020 21:41:55 +0000 (00:41 +0300)] 
lib-storage: Use mailbox.event as parent to mail_index

The index lives longer than the struct mailbox, which is a bit confusing.
In some cases the index could even be used for a different mailbox name
(symlink/alias), in which case the event's mailbox name wouldn't be exactly
correct. However, these downsides are still preferable to not inheriting
from the mailbox event, since then there is no mailbox name.

5 years agolib-index: When cache purging causes changes to be lost, don't update deleted_record_...
Timo Sirainen [Tue, 31 Mar 2020 12:20:33 +0000 (15:20 +0300)] 
lib-index: When cache purging causes changes to be lost, don't update deleted_record_count

The new file that purging created doesn't have any of these deleted records
anymore.

5 years agolib-storage: Rename mail_cache_compress_* settings to mail_cache_purge_*
Timo Sirainen [Tue, 31 Mar 2020 12:03:16 +0000 (15:03 +0300)] 
lib-storage: Rename mail_cache_compress_* settings to mail_cache_purge_*

The old settings are still recognized by the old-set-parser.

5 years agolib-index: Rename cache compress -> cache purge
Timo Sirainen [Tue, 31 Mar 2020 11:59:25 +0000 (14:59 +0300)] 
lib-index: Rename cache compress -> cache purge

Using "purge" term is less confusing than "compress". This was already
decided earlier for "doveadm mailbox cache purge" name, and it's similar
to mdbox purging.

5 years agolib-index: Rename mail-cache-compress.c to mail-cache-purge.c
Timo Sirainen [Tue, 31 Mar 2020 11:49:42 +0000 (14:49 +0300)] 
lib-index: Rename mail-cache-compress.c to mail-cache-purge.c

5 years agolib-index: Make sure cache header is written after changing cache decisions
Timo Sirainen [Sun, 5 Apr 2020 17:42:12 +0000 (20:42 +0300)] 
lib-index: Make sure cache header is written after changing cache decisions

Remove the extra check that caused it to wrongly not be updated in some
situations.

5 years agolib-index: Update last_used field immediately when adding a new cache field
Timo Sirainen [Sun, 5 Apr 2020 17:41:28 +0000 (20:41 +0300)] 
lib-index: Update last_used field immediately when adding a new cache field

Otherwise the newly added field could be dropped immediately on the next
purge.

5 years agolib-index: Make sure purging clears saved bitmask offsets state between mails
Timo Sirainen [Wed, 1 Apr 2020 21:29:07 +0000 (00:29 +0300)] 
lib-index: Make sure purging clears saved bitmask offsets state between mails

This is just to make sure it doesn't try to use previous mail's offset when
merging bitmasks. This shouldn't have been possible anyway, because
field_seen array guaranteed that the bitmask_pos was always set before
reading it. This just makes extra sure of it.

5 years agolib-index: Fix mail_cache_get_first_new_seq() when all mails are old
Timo Sirainen [Wed, 1 Apr 2020 21:27:43 +0000 (00:27 +0300)] 
lib-index: Fix mail_cache_get_first_new_seq() when all mails are old

Instead of returning "all messages are old", it returned "all messages are
new".

5 years agolib-index: mail_cache_get_missing_reason() - Add "Mail is already expunged" as reason
Timo Sirainen [Wed, 1 Apr 2020 13:42:35 +0000 (16:42 +0300)] 
lib-index: mail_cache_get_missing_reason() - Add "Mail is already expunged" as reason

5 years agolib-index: Remove mail_cache_try_lock()
Timo Sirainen [Wed, 1 Apr 2020 19:24:59 +0000 (22:24 +0300)] 
lib-index: Remove mail_cache_try_lock()

5 years agolib-index: Wait for lock in cache compression, not just try once
Timo Sirainen [Tue, 31 Mar 2020 15:53:33 +0000 (18:53 +0300)] 
lib-index: Wait for lock in cache compression, not just try once

Sometimes there's an important reason for the cache to be compressed, and it
shouldn't give up just because there's a race condition with another process
that just happens to be writing to it.

5 years agolib-index: After cache is marked corrupted, don't log error if cache file isn't found
Timo Sirainen [Tue, 31 Mar 2020 14:50:42 +0000 (17:50 +0300)] 
lib-index: After cache is marked corrupted, don't log error if cache file isn't found

It's just an unnecessary extra error.

5 years agolib-index: Don't compress cache file if there are cache transactions with changes
Timo Sirainen [Wed, 1 Apr 2020 19:19:52 +0000 (22:19 +0300)] 
lib-index: Don't compress cache file if there are cache transactions with changes

The cache compression could have lost changes in the uncommitted
transactions if they had already written some changes to the file.
This seems to have happened sometimes at least with dsync.

5 years agolib-index: Cache compression could have lost data for recently added mails
Timo Sirainen [Wed, 1 Apr 2020 13:31:32 +0000 (16:31 +0300)] 
lib-index: Cache compression could have lost data for recently added mails

mail_index_sync_ctx.view may not have seen all the newly added mails,
which caused compression to skip those mails. Use a whole new view
instead, which guarantees that all mails are seen.

5 years agolib-index: Fix cache lookup for a newly added field in non-committed transaction
Timo Sirainen [Tue, 31 Mar 2020 09:08:43 +0000 (12:08 +0300)] 
lib-index: Fix cache lookup for a newly added field in non-committed transaction

The cache lookup didn't return anything unless the field already existed in
the current cache file. It could still have already been added to the
transaction and found from there.

5 years agolib-index: Don't even try to add fields to cache that exceed record_max_size
Timo Sirainen [Tue, 31 Mar 2020 08:40:58 +0000 (11:40 +0300)] 
lib-index: Don't even try to add fields to cache that exceed record_max_size

Previously these were temporarily added to memory and later on the whole
cache record was just dropped. But usually not all the cache fields are
huge, so it's better to add some fields to cache than none.

5 years agolib-index: Fix assert-crash if cache record has no content after all
Timo Sirainen [Wed, 1 Apr 2020 15:02:43 +0000 (18:02 +0300)] 
lib-index: Fix assert-crash if cache record has no content after all

This couldn't have happened yet, but will happen after the next commit.

5 years agolib-index: Use cache record's exact size when checking if it should be flushed
Timo Sirainen [Tue, 31 Mar 2020 08:37:39 +0000 (11:37 +0300)] 
lib-index: Use cache record's exact size when checking if it should be flushed

The field_idx wasn't included in the calculation.

5 years agolib-index: Replace mail_cache_flush_and_unlock() with mail_cache_unlock() where it...
Timo Sirainen [Mon, 30 Mar 2020 14:39:46 +0000 (17:39 +0300)] 
lib-index: Replace mail_cache_flush_and_unlock() with mail_cache_unlock() where it's better

In various error handling code paths it's not useful to try to flush any
headers. It might just make things worse.

5 years agolib-index: Remove backward compatibility code for Dovecot v2.1 and older
Timo Sirainen [Mon, 30 Mar 2020 14:49:35 +0000 (17:49 +0300)] 
lib-index: Remove backward compatibility code for Dovecot v2.1 and older

We can still read old cache files, but Dovecot v2.1 can't anymore read these
newer cache files.

5 years agolib-index: Cache transaction rollback used too small value to increase deleted_record...
Timo Sirainen [Wed, 1 Apr 2020 19:11:21 +0000 (22:11 +0300)] 
lib-index: Cache transaction rollback used too small value to increase deleted_record_count

Rollback used records_written to update it, but that was actually counting
the number of transaction flushes, not the number of individual mail cache
records that were written.

5 years agolib-index: mail_cache_transaction_rollback() - fix updating deleted_record_count
Timo Sirainen [Mon, 30 Mar 2020 14:34:45 +0000 (17:34 +0300)] 
lib-index: mail_cache_transaction_rollback() - fix updating deleted_record_count

The deleted_record_count in cache header wasn't actually being updated
because hdr_modified wasn't TRUE.

5 years agolib-index: Add mail_cache_unlock() that doesn't flush any headers
Timo Sirainen [Mon, 30 Mar 2020 14:28:41 +0000 (17:28 +0300)] 
lib-index: Add mail_cache_unlock() that doesn't flush any headers

5 years agolib-index: Rename mail_cache_unlock() to mail_cache_flush_and_unlock()
Timo Sirainen [Mon, 30 Mar 2020 14:22:38 +0000 (17:22 +0300)] 
lib-index: Rename mail_cache_unlock() to mail_cache_flush_and_unlock()

This describes better what it does, because it's not just unlocking.

5 years agolib-index: Make mail_cache_need_reopen() static
Timo Sirainen [Mon, 30 Mar 2020 14:14:10 +0000 (17:14 +0300)] 
lib-index: Make mail_cache_need_reopen() static

Nothing else besides mail_cache_*lock() needs to be calling it anymore.

5 years agolib-index: mail_cache_lookup_offset() - Use mail_cache_sync_reset_id()
Timo Sirainen [Mon, 30 Mar 2020 14:12:50 +0000 (17:12 +0300)] 
lib-index: mail_cache_lookup_offset() - Use mail_cache_sync_reset_id()

This avoids race conditions where cache fields aren't found during cache
compression.

5 years agolib-index: Make mail_cache_sync_reset_id() public
Timo Sirainen [Mon, 30 Mar 2020 14:07:14 +0000 (17:07 +0300)] 
lib-index: Make mail_cache_sync_reset_id() public

Also it no longer requires that cache is already locked when being called.

5 years agolib-index: Mark cache corrupted after finding that reset_id permanently wrong
Timo Sirainen [Mon, 30 Mar 2020 14:04:24 +0000 (17:04 +0300)] 
lib-index: Mark cache corrupted after finding that reset_id permanently wrong

5 years agolib-index: mail_cache_*lock() - On reset_id mismatch wait for cache compression to...
Timo Sirainen [Mon, 30 Mar 2020 13:48:21 +0000 (16:48 +0300)] 
lib-index: mail_cache_*lock() - On reset_id mismatch wait for cache compression to finish

It was possible that the reset_id mismatch happened because cache
compression had already recreated the .cache file, but hadn't yet written
the new reset_id to the .log file. By waiting for the .log lock, we can be
sure that this won't happen.

5 years agolib-index: mail_cache_sync_reset_id() - Rewrite to simplify
Timo Sirainen [Mon, 30 Mar 2020 12:45:57 +0000 (15:45 +0300)] 
lib-index: mail_cache_sync_reset_id() - Rewrite to simplify

This doesn't change any functionality.

5 years agolib-index: mail_cache_*lock() - Handle syscall errors correctly
Timo Sirainen [Mon, 30 Mar 2020 12:13:56 +0000 (15:13 +0300)] 
lib-index: mail_cache_*lock() - Handle syscall errors correctly

If reading a cache file failed because of some temporary syscall error, it
was treated the same as if the cache was corrupted. This could have
caused compression to lose cached data.

5 years agolib-index: mail_cache_reopen_now() - Fix corruption handling remove checking if reset...
Timo Sirainen [Mon, 30 Mar 2020 13:16:46 +0000 (16:16 +0300)] 
lib-index: mail_cache_reopen_now() - Fix corruption handling remove checking if reset_id matches

reset_id checking is already done by all of the callers. Also simplify the
error vs corruption handling by using mail_cache_open_and_verify()

5 years agolib-index: Make mail_cache_need_reopen() public and require using it explicitly
Timo Sirainen [Mon, 30 Mar 2020 13:24:45 +0000 (16:24 +0300)] 
lib-index: Make mail_cache_need_reopen() public and require using it explicitly

mail_cache_reopen() no longer implicitly calls it.

5 years agolib-index: mail_cache_open_and_verify() - Separate error and corruption handling
Timo Sirainen [Mon, 30 Mar 2020 12:25:49 +0000 (15:25 +0300)] 
lib-index: mail_cache_open_and_verify() - Separate error and corruption handling

5 years agolib-index: mail_cache_need_reopen() - Don't skip reopen just because compression...
Timo Sirainen [Mon, 30 Mar 2020 12:07:40 +0000 (15:07 +0300)] 
lib-index: mail_cache_need_reopen() - Don't skip reopen just because compression is wanted

The new cache file may still be usable until the compression is done.

5 years agolib-index: mail_cache_map_all() - Separate error and corruption handling
Timo Sirainen [Mon, 30 Mar 2020 15:41:26 +0000 (18:41 +0300)] 
lib-index: mail_cache_map_all() - Separate error and corruption handling

5 years agolib-index: Remove cache compression dotlock
Timo Sirainen [Fri, 27 Mar 2020 20:57:14 +0000 (22:57 +0200)] 
lib-index: Remove cache compression dotlock

Now that .log file is guaranteed to be locked during cache compression,
there's no need for another exclusive lock.

5 years agolib-index: Fix checking if cache should be compressed because it's getting too large
Timo Sirainen [Tue, 31 Mar 2020 13:43:07 +0000 (16:43 +0300)] 
lib-index: Fix checking if cache should be compressed because it's getting too large

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.

5 years agolib-index: Check if maximum cache file size has reached only after locking
Timo Sirainen [Fri, 27 Mar 2020 16:26:23 +0000 (18:26 +0200)] 
lib-index: Check if maximum cache file size has reached only after locking

This avoids race conditions.

5 years agolib-index: mail_cache_compress_with_trans() - Don't return lock anymore
Timo Sirainen [Fri, 27 Mar 2020 11:02:37 +0000 (13:02 +0200)] 
lib-index: mail_cache_compress_with_trans() - Don't return lock anymore

Now that transaction log is always locked during cache compression, it
doesn't matter if the cache is unlocked before or after the transaction log
commit.

5 years agolib-index: mail_cache_compress_with_trans() - Require that transaction log is locked
Timo Sirainen [Fri, 27 Mar 2020 11:01:57 +0000 (13:01 +0200)] 
lib-index: mail_cache_compress_with_trans() - Require that transaction log is locked

This should be true now for all of its callers.

5 years agolib-index: mail_cache_compress() - Make sure compression sees the latest changes...
Timo Sirainen [Mon, 30 Mar 2020 15:05:42 +0000 (18:05 +0300)] 
lib-index: mail_cache_compress() - Make sure compression sees the latest changes in index

5 years agolib-index: mail_cache_compress() - Keep the .log file locked during compression
Timo Sirainen [Fri, 27 Mar 2020 10:53:32 +0000 (12:53 +0200)] 
lib-index: mail_cache_compress() - Keep the .log file locked during compression

5 years agolib-index: Remove mail_cache_compress_forced()
Timo Sirainen [Fri, 27 Mar 2020 10:44:27 +0000 (12:44 +0200)] 
lib-index: Remove mail_cache_compress_forced()

5 years agodoveadm: Rewrite "doveadm mailbox cache purge" to use mail_cache_compress()
Timo Sirainen [Fri, 27 Mar 2020 10:49:40 +0000 (12:49 +0200)] 
doveadm: Rewrite "doveadm mailbox cache purge" to use mail_cache_compress()

Also removed checks to verify whether the cache file existed or was usable.
Compression will create/fix the file, which is more likely to be the wanted
behavior than failing.

5 years agolib-index: mail_cache_compress*() - Add compress_file_seq parameter
Timo Sirainen [Fri, 27 Mar 2020 10:36:40 +0000 (12:36 +0200)] 
lib-index: mail_cache_compress*() - Add compress_file_seq parameter

This can be used to specify when the cache file should be compressed.
This was previously hidden in the cache->compress_file_seq field, but
now it's more explicit.

This commit also makes sure that cache is compressed when index rebuilding
is done.

5 years agolib-index: Use mail_cache_compress() where possible
Timo Sirainen [Fri, 27 Mar 2020 10:22:37 +0000 (12:22 +0200)] 
lib-index: Use mail_cache_compress() where possible

5 years agolib-index: Add mail_cache_compress()
Timo Sirainen [Fri, 27 Mar 2020 10:19:47 +0000 (12:19 +0200)] 
lib-index: Add mail_cache_compress()

5 years agolib-index: Rename mail_cache_compress() to mail_cache_compress_with_trans()
Timo Sirainen [Fri, 27 Mar 2020 10:16:02 +0000 (12:16 +0200)] 
lib-index: Rename mail_cache_compress() to mail_cache_compress_with_trans()

5 years agolib-index: mail_cache_decisions_copy() - Create transaction internally
Timo Sirainen [Fri, 27 Mar 2020 09:33:23 +0000 (11:33 +0200)] 
lib-index: mail_cache_decisions_copy() - Create transaction internally

5 years agolib-index: Simplify opening cache when locking transaction
Timo Sirainen [Thu, 26 Mar 2020 16:04:13 +0000 (18:04 +0200)] 
lib-index: Simplify opening cache when locking transaction

All this work is already done by mail_cache_lock() or
mail_cache_transaction_lock() after locking has failed.

5 years agolib-index: If cache transaction lock fails because reset_id mismatch, compress cache
Timo Sirainen [Fri, 27 Mar 2020 16:07:53 +0000 (18:07 +0200)] 
lib-index: If cache transaction lock fails because reset_id mismatch, compress cache

This is also done in mail_cache_transaction_open_if_needed(), so it usually
worked anyway. But that function is otherwise unnecessary, so it's going
away in the next commit.

5 years agolib-index: Refresh caching decisions from cache file once per transaction
Timo Sirainen [Thu, 26 Mar 2020 14:54:03 +0000 (16:54 +0200)] 
lib-index: Refresh caching decisions from cache file once per transaction

If another process had updated the decisions, mail_cache_field_want_add()
and mail_cache_field_can_add() may have returned obsolete values.

5 years agolib-index: If cache transaction flush fails, don't discard the last mail's cached...
Timo Sirainen [Thu, 26 Mar 2020 14:16:06 +0000 (16:16 +0200)] 
lib-index: If cache transaction flush fails, don't discard the last mail's cached data

The last mail's cached data could still be accessed within memory.

This can now be done because the field indexes are internal indexes instead
of file-specific indexes.