Timo Sirainen [Fri, 18 Aug 2017 14:34:14 +0000 (17:34 +0300)]
lib-index: Add mail_cache_close_mail() to smartly drop cached data with INDEX=MEMORY
Instead of reseting the entire transaction buffer when 256 kB is reached,
just drop mails have have been marked closed with mail_cache_close_mail().
If that's not enough, continue deleting forcibly until the buffer is below
256 kB.
This is especially important when mail_prefetch_count>0 and INDEX=MEMORY.
In that case there can be multiple mails that are being added to cache
and used later on. If they were dropped from cache too early, the work
would have to be done all over again.
Timo Sirainen [Fri, 18 Aug 2017 08:09:41 +0000 (11:09 +0300)]
director: Fix rapid reconnection on failed outgoing connections
last_network_failure wasn't set, which caused a failed outgoing connection
to immediately reconnect to it. This resulted in rapid logging of
connect() errors.
Timo Sirainen [Thu, 10 Aug 2017 14:50:04 +0000 (17:50 +0300)]
director: Make sure users gets expired even on an idle director
Normally expiring gets done while looking up users, but if nothing is doing
that on an idle director the users won't get expired. This can cause confusion
in "doveadm director status" output.
Without this fix, if the new message does not contain a from, a subject, and
a snippet the generated JSON will be malformed (the status check at the end
appended a '"' when it shouldn't have).
Sergey Kitov [Tue, 15 Aug 2017 08:09:07 +0000 (11:09 +0300)]
auth: auth_request_log_unknown_user() to call common auth_request_log_login_failure()
Separate implementation of auth_request_log_unknown_user() is
replaced with call to auth_request_log_login_failure()
NOTE: behavior of the auth_request_log_unknown_user() is changed and
is in line with auth_request_log_password_mismatch()
Timo Sirainen [Mon, 14 Aug 2017 12:44:24 +0000 (15:44 +0300)]
cassandra: Fix confusing debug logging for paged query results.
Even when caller supported paged queries, the debug output contained
"Paged query has more results, but not supported by the caller".
Clear out the error after sql_result_more() is called, so it won't be
logged.
Timo Sirainen [Sat, 5 Aug 2017 05:33:12 +0000 (14:33 +0900)]
lib-index: Fix setting highest_modseq correctly in mail_index_modseq_header
The internally counted ctx->highest_modseq wasn't correct if all of the
records weren't synced. This could have happened for various reasons.
Since the view's current log seq/offset is used for the header, we can
also use the current highest_modseq from the view as well and it's
guaranteed to be correct.
This fixes various potential problems with using QRESYNC and CONDSTORE
extensions. It also fixes potential errors with unhibernating imap
clients, including:
Error: .../dovecot.index.log: Transaction log changed unexpectedly, can't get modseq
Timo Sirainen [Sat, 5 Aug 2017 05:29:12 +0000 (14:29 +0900)]
lib-index: Update per-flag modseq value a bit more correctly.
This changes the code to be similar to the per-mail modseq updating in
mail_index_modseq_update(). It probably wasn't exactly wrong previously
either, but this change is required for the following commits.
Timo Sirainen [Sat, 5 Aug 2017 05:11:17 +0000 (14:11 +0900)]
lib-index: Fix modseq tracking with multiple flag updates
The earlier code was checking only the first flag record update. If the
first one had only internal flag changes but (some of) the rest didn't,
the modseq wasn't counted correctly. This was probably pretty rare.
Timo Sirainen [Sat, 5 Aug 2017 05:07:58 +0000 (14:07 +0900)]
lib-index: Fix modseq tracking for MAIL_INDEX_MAIL_FLAG_UPDATE_MODSEQ
This is used to increase modseq for mails when their private flags change.
Use an already existing MAIL_TRANSACTION_FLAG_UPDATE_IS_INTERNAL() that
does this properly.
(This change preserves another bug, which is fixed in the next commit.)
Timo Sirainen [Wed, 9 Aug 2017 10:23:36 +0000 (13:23 +0300)]
push-notification: Switch to main ioloop while calling drivers' deinit/cleanup callbacks
Continues a44595f7b1afc7ccbd8653598753b32899d01c76 to other functions.
For example the OX backend would call http_client_wait(), which would move
the I/Os and timeouts to the current ioloop, which might not be main_ioloop
always. When that ioloop gets destroyed, I/O and timeout leaks are logged
and eventually the process crashes when calling http_client_deinit() in
cleanup() (this would happen later for another mail_user).
Timo Sirainen [Tue, 8 Aug 2017 19:11:48 +0000 (22:11 +0300)]
lib: Add asserts to make sure running ioloop is always current_ioloop
We could also switch current_ioloop to the running ioloop temporarily while
calling callbacks, but this behavior is probably clearer. All of the
existing code should already work this way.
Add the asserts after IO or timeout callback is called, so if the assert
triggers, we can find out which callback caused the change. The initial
assert in io_loop_handler_run() is enough to verify that the initial
ioloop is correct.
Aki Tuomi [Thu, 20 Jul 2017 05:49:25 +0000 (08:49 +0300)]
dict-ldap: Escape LDAP search filter properly
This is syntaxical escaping to make ldap servers accept queries
with escapable characters, instead of erroring out. It is possible
that the filter could have been modified in unexpected ways
if the input comes from untrusted sources.
Timo Sirainen [Tue, 25 Jul 2017 17:53:18 +0000 (20:53 +0300)]
lib-storage: Hide and rmdir \NoSelect leaf mailboxes with NO-NOSELECT
If the leaf is successfully rmdir()ed, rmdir() also its parents.
This doesn't work perfectly with if there are multiple levels of \NoSelect
mailboxes. For example with "a/b/c" the listing will already have returned
"a" and "a/b" before it reaches the "a/b/c" code, which will rmdir all of
them, but it's a bit too late at that point. It's too much work to fix
though, and the situation will be fixed on the next list anyway.
This controls whether to update INBOX's STATUS information in the mailbox
list index. It can be useful especially if LISTINDEX points to a tmpfs,
but perhaps also in other situations.
I considered adding a more generic setting to exclude other mailboxes, but
the namespace prefixes and hierarchy separators get a bit complicated with
shared mailboxes. It's probably also not very useful to change this for
anything but the INBOX.
Timo Sirainen [Fri, 21 Jul 2017 16:52:23 +0000 (19:52 +0300)]
virtual: Make sure index is rewritten when new mailboxes are added
Otherwise multiple bbox->sync_mailbox_idx point to 0 and they keep overwriting
each others in the header. This causes the header to be constantly updated with
wrong contents.
Aki Tuomi [Thu, 20 Jul 2017 08:01:37 +0000 (11:01 +0300)]
virtual: Do not remove mailbox notify if the mailbox is closed
The backend mailbox close/open status is not related to
the notify API usage. The notify is removed in
virtual_mailbox_close_internal instead when we are
actually deinitializing.
Timo Sirainen [Wed, 19 Jul 2017 10:43:09 +0000 (13:43 +0300)]
lib-index: Fix next_uid lookup in open transaction that has appended mails
The appended mails were used for returning an updated
mail_index_header.next_uid, but only if the mails were assigned UIDs in
mail_index_append(). It should have updated the next_uid also after
mail_index_append_finish_uids() was used to assign the UIDs.
This fixes setting first_recent_uid correctly for virtual mailboxes when the
sync finds new mails. Avoids multiple sessions from getting \Recent flags
for the same mails.