Timo Sirainen [Fri, 14 Jul 2017 14:00:21 +0000 (17:00 +0300)]
master: Change service "connections are being dropped" warning interval to 1 second
When this is happening, it's often accompanied with all kinds of other errors and
these warnings drown in them. Make them easier to notice by reducing the interval
from 60 seconds to 1 second.
Timo Sirainen [Thu, 13 Jul 2017 23:11:56 +0000 (02:11 +0300)]
lib-storage: When index dir rmdir() fails with ENOTEMPTY, retry it for 1 second
This helps to avoid leaving those index directories lying around with NFS.
Hopefully within the 1 second any existing processes that have been keeping those
files open have finished their task. Especially IMAP IDLE will take 0.5 seconds
to start syncing indexes and realize that they're deleted.
Timo Sirainen [Thu, 13 Jul 2017 22:54:31 +0000 (01:54 +0300)]
lib-index: If refreshing finds dovecot.index.log gone, assume the mailbox was deleted
Don't try to recreate the log file again. It can just cause further problems.
A way to reproduce this problem with NFS when INDEX dir is specified:
* create mailbox foo, select foo, IDLE
* delete mailbox foo
--> foo's index is recreated back by IDLEing process
Timo Sirainen [Wed, 12 Jul 2017 23:56:33 +0000 (02:56 +0300)]
quota: When setting auto_updating to transaction, skip invisible quota roots
Skip the quota root also if the mailbox matches "ignore" quota_rule.
This is only an optimization fix so that unnecessary work isn't done for
quota roots that aren't actually used.
Make sure the directory isn't created if the mail root directory no longer
exists. This might happen during mailbox deletion when another process is
opening the mailbox at the same time.
Timo Sirainen [Tue, 11 Jul 2017 12:35:16 +0000 (15:35 +0300)]
lib-index: Track .log.2 rotation time in index header
This avoids unnecessarily stat()ing the file. Also it's a bit better
since it's tracking the actual rotation time, not the mtime of what the
.log file happened to have at the time of rotation.
The initial rotation timestamp is written only to the dovecot.index header
without going through dovecot.index.log. This works, because the
dovecot.index is written practically always after a log rotation. For the
rare cases when it doesn't happen, the dovecot.index.log.2 just gets
deleted later after the next log rotation.
Timo Sirainen [Tue, 11 Jul 2017 12:33:56 +0000 (15:33 +0300)]
lib-index: Check .log.2 rotation only when syncing
Instead of also whenever appending transactions to .log file. This
shouldn't change the behavior much, and it's needed for the following
change to work correctly.
Aki Tuomi [Tue, 11 Jul 2017 07:45:16 +0000 (10:45 +0300)]
lib-storage: Remove user namespaces on hook error
If there is a hook error during namespaces added
remove the namespaces from user. This avoids attempts
to use the namespaces later on without proper initialization.
Timo Sirainen [Mon, 10 Jul 2017 13:11:48 +0000 (16:11 +0300)]
lib-storage: Fix mailbox_update() to always update mailbox list index.
It previously was updating it only if the list index for the mailbox was
already fully up-to-date. But that doesn't really matter, because
mailbox_update() is supposed to be changing the values regardless.
This fixes mailbox_update() to always work with LAYOUT=index. It also
fixes mailbox_update() for INBOX to update UIDVALIDITY/GUID.
Timo Sirainen [Thu, 6 Jul 2017 14:45:02 +0000 (17:45 +0300)]
lib-storage: Set mailbox list index to be refreshed after changes, not before
Mailbox deletion and rename set the refresh-flag before the change was done.
This was unnecessary if the change didn't happen. Also there was a race
condition that another process could have done the refresh before the
change was even done.
Timo Sirainen [Mon, 10 Jul 2017 11:37:04 +0000 (14:37 +0300)]
lib-storage: Try to avoid opening mailbox list index on mailbox access
Perform the STATUS (and other relevant) updates only if syncing or
transaction commits changed anything. This could be optimized further to
check even more strongly whether the seen changes could cause changes to
the list index, but it's probably not worth the effort.
There were several issues with our usage of Boehm GC:
- it didn't help with memory fragmentation
- it is not very efficient
- it was rarely enabled & used
Proper use of a GC would involve radical changes to how we write code
and cause portability issues. We can get most of the benefits of a GC
with data stacks and alloc-only memory pools.
Aki Tuomi [Wed, 28 Jun 2017 10:45:19 +0000 (13:45 +0300)]
virtual: Fix keywords handling
Keywords are per-mail object, and should be treated as one. The old
code left pointer to keywords dandling which lead into double-free.
Now the ctx->data is treated in similar way as other backends.
loops in client_input_data_write_local() and in client_deliver_next()
are merged as they are essentially the same loop,
client_deliver_next() renamed to client_deliver_to_rcpts().
Aki Tuomi [Tue, 4 Jul 2017 11:22:19 +0000 (14:22 +0300)]
notify-status: Add notify-status plugin
This enables updating a dictionary with mailbox
status information when the mailbox changes.
It requires notify_status_dict setting for specifying
the dict where the data is stored.
One can optionally use notify_status_mailbox patterns
for specifying which box(es) the status update is done.
Subsequent patterns are notify_status_mailbox2 and so forth.
One can also specify data format using notify_status_value
plugin setting.
Stephan Bosch [Mon, 27 Mar 2017 22:03:04 +0000 (00:03 +0200)]
lib-http: server: Implemented API for handling the incoming request payload in the background.
It allows forwarding the incoming payload to an output stream (e.g. iostream-temp) or to a buffer.
The maximum size of the payload is configurable. The client will get a 413 error if the maximum is exceeded.
Stephan Bosch [Tue, 28 Mar 2017 22:17:50 +0000 (00:17 +0200)]
lib-http: server: Allow holding only a reference to the request payload stream, rather than the request itself.
This mimics the http-client behavior in this case.
It makes the implementation of the background payload handling API in subsequent commits a little simpler.
Using strchr() was splitting login and host at the first
occurrence of '@' which leads to troublesome behaviour.
When calling strace one would notice the misbehaviour:
Timo Sirainen [Mon, 3 Jul 2017 18:08:02 +0000 (21:08 +0300)]
imapc: Prefech - Initialize cached stream only if needed
If the mail is immediately accessed for other purposes (e.g. fetching
message flags), there's no need to go through all the trouble of
initializing the mail stream.
Timo Sirainen [Fri, 30 Jun 2017 10:46:22 +0000 (13:46 +0300)]
lib-storage: Fix ITERINDEX to leave \NoSelect parents after deleting child mailbox
For example if "a/b" was created and deleted, "a" should be left behind.
(Or at least it shouldn't have left "a" to mail root directory and kept it
invisible since it didn't exist in index dir.)
Also add index_mailbox_update_last_temp_file_scan() for easily updating it.
This is reusing an old "sync timestamp" field. Because it was a timestamp,
it doesn't matter if the old data still exists in it. This field could have
been added as an extension, but that's more work and this feature is generic
enough that it should be useful for many of the mail storage backends.
Timo Sirainen [Mon, 26 Jun 2017 16:30:11 +0000 (19:30 +0300)]
lib-storage: Check for storage existence from index dir with ITERINDEX
The root path creation doesn't really even seem to be necessary, because any
mailbox access will automatically mkdir the missing directories anyway.
Although writing other files might not work so well, such as
mail_attribute_dict that points inside the mail directory.
This change simply changes the mailboxes/ directory to be looked up from
index directory instead of the mail root directory. It also mkdirs the
index/mailboxes/ directory afterwards if it didn't exist. So practically
this change shouldn't break anything, since the mailboxes/ directory should
always exist for both root and the indexes.
Timo Sirainen [Mon, 26 Jun 2017 17:10:17 +0000 (20:10 +0300)]
lib-storage: Add mail_location=..:ITERINDEX
This changes mailbox list iteration to work using INDEX directory instead of
the normal mail directory. This can be helpful when the indexes are stored
on a faster storage.
Timo Sirainen [Fri, 30 Jun 2017 10:56:54 +0000 (13:56 +0300)]
lib-storage: Fix mailbox delete to not delete childrens' INDEX or CONTROL dirs
If mail_location had separate INDEX and/or CONTROL set, deleting a mailbox
with children caused the childrens' index and/or control directories to be
deleted (but the mail/ALT directories weren't).
I'm not sure why the _FLAG_MAILBOX_FILES was treated as a special case
earlier. It shouldn't make a difference.
It should return error on unexpected readdir(), closedir() and unlink()
failures. Also fix handling a race condition with another process deleting
the mailbox at the same time.
Timo Sirainen [Tue, 27 Jun 2017 13:37:16 +0000 (16:37 +0300)]
lib-storage: Use mailbox_list_delete_finish_ret() for fs & maildir++ layout
Fixes a problem where e.g. index directory existed but mail root didn't,
and the mailbox couldn't be fully deleted. This was especially a problem
with ITERINDEX enabled.
It means that the user's home directory doesn't exist, which is pretty
unexpected. Home directory is supposed to be created when the storage is
initialized.