Timo Sirainen [Wed, 11 May 2016 20:58:59 +0000 (16:58 -0400)]
dict-sql: Cache reading settings files.
The settings were read for every dict init, which was done for every new
dict connection. This was using a lot of CPU. There are usually only a
couple dict-sql settings files, so we cache all of the ones we read.
Timo Sirainen [Tue, 10 May 2016 21:35:43 +0000 (17:35 -0400)]
lib-ldap: Reverted previous commit for now.
We don't have libdovecot built at at this stage. But we can't build it
earlier, because it needs lib-dict-extra, which needs lib-ldap. So we have
cyclical dependencies now.
Timo Sirainen [Thu, 5 May 2016 18:26:37 +0000 (21:26 +0300)]
stats: Handle getrusage() errors better
I'm not aware of these errors actually happening anywhere, but its
error handling wouldn't have been correct if previous getrusage() calls
had succeeded. Now if it fails, log an error once and just keep on using
the last working rusage.
We can't just treat i_stream_get_size() returning 0 as the reason being
istream is async and not fully read. It might be, but it might also be
because of other reasons. And since we're closing the istream we couldn't
even properly finish up the async handling. So for now just return an
error if we see this happening.
This probably doesn't affect the results much, since the stream_errno is set
anyway. But it's better to abort early, just in case the broken state might
end up asserting later.
Timo Sirainen [Tue, 3 May 2016 12:27:22 +0000 (15:27 +0300)]
lib-storage: Fixed potential crash in mailbox_sync_deinit() error handling
If mailbox_sync*() was called before mailbox was opened, the automatic
mailbox opening could fail. mailbox_sync_deinit() would still try to access
box->view, which would be NULL.
Timo Sirainen [Mon, 2 May 2016 12:20:18 +0000 (15:20 +0300)]
lib-ldap: Added initial connection pooling code.
This is mainly about allowing multiple dict-ldaps to use the same
ldap-connection. In future we could support load balancing with multiple
concurrent LDAP connections.
Timo Sirainen [Mon, 2 May 2016 11:21:06 +0000 (14:21 +0300)]
dict-ldap: Don't reuse dict for different usernames.
Fixes doing priv/* lookups for multiple usernames.
This currently also means that each username will create a separate LDAP
connection, which isn't ideal. But this is probably better fixed in
lib-ldap code similar to how lib-sql does connection pooling.
Timo Sirainen [Sat, 30 Apr 2016 11:55:14 +0000 (14:55 +0300)]
lib-storage: Clear list error before mailbox_list_get_hierarchy_sep()
With ACL plugin enabled the call could have triggered dovecot-acl-list
rebuild, which in turn could have set list errors if it didn't have
permissions to all the mailboxes. This caused IMAP logins to fail.
Timo Sirainen [Sat, 30 Apr 2016 11:19:02 +0000 (14:19 +0300)]
lib-mail: message-parser assert-crashfix
Crashes when multipart MIME header is missing end-of-headers line and the
boundary begins with the same prefix as one of the parent boundaries.
Broken by 7a12331c6
Timo Sirainen [Thu, 28 Apr 2016 19:33:14 +0000 (22:33 +0300)]
lib: Set timestamp part more accurately in guid_128_generate()
Previously a long-running process would keep the timestamp close to its
original start time. This doesn't really matter as long as GUIDs are treated
opaque, but some pieces of code prefer to try to use the timestamp fields
since they're already there. This makes such code work more nicely.
Timo Sirainen [Fri, 29 Apr 2016 16:25:52 +0000 (19:25 +0300)]
quota: Added quota_over_flag_lazy_check flag.
By default the quota_over_flag is checked immediately at startup. With this
option the check is done only at a time when the quota is anyway being read.
Timo Sirainen [Fri, 29 Apr 2016 12:50:06 +0000 (15:50 +0300)]
global: Use buffer_get_writable_size() where possible
With 09539f3db increasing buffer's init_size with +1 some fts-icu unit tests
started failing. And in general it's better to use the writable size since
that provides the true size that can be used.
Timo Sirainen [Fri, 29 Apr 2016 12:42:48 +0000 (15:42 +0300)]
quota: Optimize handling a large number of expunges.
This assumes that the mail_expunge() was called in the same order as
sync_notify(), which practically means that they were both done in
ascending uid order. This is usually true.
Timo Sirainen [Fri, 29 Apr 2016 11:07:05 +0000 (14:07 +0300)]
lib-index: Use a bit larger initial records buffer size
For example with a mailbox having 160k messages the buffer size is around
10MB. Adding just 1% more space to it allows a lot more appends before the
buffer needs to be realloced. This reduces CPU usage quite a lot.
Timo Sirainen [Fri, 29 Apr 2016 09:55:52 +0000 (12:55 +0300)]
lib: Use p_malloc() explicitly in first buffer_alloc()
Although there is now code in p_realloc() that it should be just as
efficient, this makes profiling somewhat nicer since it can better
distinguish between actual reallocs and initial allocs.
Timo Sirainen [Mon, 25 Apr 2016 13:58:30 +0000 (16:58 +0300)]
lib-mail: More fixes to istream-header-filter with large input.
Don't assume that when reading the header the second time we'll get exactly
the same header blocks as the first time.
This commit also prevents the filter callback from switching the
matching-decision on non-first header line. This shouldn't be needed and it
could just cause confusion. (It also made it a bit easier to implement this
fix.)
Timo Sirainen [Mon, 25 Apr 2016 13:34:59 +0000 (16:34 +0300)]
lib-mail: Improved istream-header-filter unit test.
Existing code already assumes that the callback is called for all the header
data. So it's not used just for filtering headers but also parsing the
header contents. Make this assumption now explicit as a unit test.
Timo Sirainen [Mon, 25 Apr 2016 11:38:35 +0000 (14:38 +0300)]
dsync: If state is invalid, exit with code 2 instead of tempfail.
We'll have dsync_mailbox_import_*() just return success to everything until
_deinit() is called. The _deinit() will return a failure and set "resync
needed"-flag, which caller will know how to handle.
Timo Sirainen [Fri, 15 Apr 2016 13:12:44 +0000 (16:12 +0300)]
lib-storage: Don't use same session ID for multiple mail_storage_service_next() calls.
dsync does multiple mail_storage_service_next() calls for the same
mail_storage_service_user. This causes stats plugin to send the same
session ID to stats process, which complains about duplicates. Solved this
in a generic way by having the following mail_storage_service_next() calls
append :counter to session ID.