Timo Sirainen [Thu, 24 Sep 2015 12:19:53 +0000 (15:19 +0300)]
lib: Fixed __builtin_object_size() usage in buffer.h
With type=3 size for unknown objects is set to 0, which causes a compiler
failure. With type=1 it's (size_t)-1, which passes the check.
Timo Sirainen [Wed, 23 Sep 2015 22:00:45 +0000 (01:00 +0300)]
lib-sql: sqlpool needs to change transaction queries' transaction pointer
Otherwise query->trans points to the sqlpool's transaction, while our
backends want it to point to the backend's transaction.
Timo Sirainen [Wed, 23 Sep 2015 19:59:55 +0000 (22:59 +0300)]
dict-client: If dict iteration was aborted, the rest of the connection state became broken.
We never continued skipping over the rest of the iteration, instead the
iteration replies were treated as replies to the following commands.
Teemu Huovila [Wed, 23 Sep 2015 11:52:44 +0000 (14:52 +0300)]
lib: Include stdlib.h in lib.h.
It's already included in so many files that we might as well include it in
lib.h for everything. This is especially needed to be able to use sort.h,
which currently is included in lib.h anyway.
Stephan Bosch [Tue, 22 Sep 2015 18:16:34 +0000 (21:16 +0300)]
lib-http: client: Fixed bug that caused queues to be duplicated over time when host has multiple IPs.
The peer address comparison did not account for the fact that the initial
queue address has no IP assigned.
Timo Sirainen [Tue, 22 Sep 2015 11:26:08 +0000 (14:26 +0300)]
quota: Make sure the limit return value is initialized when quota_get_resource() returns 0
Later on a debug log message in quota_over_flag_check_root() was accessing
the limit, which wasn't necessarily initialized.
Also initialized value return value just as well to be safe.
Timo Sirainen [Mon, 21 Sep 2015 22:05:09 +0000 (01:05 +0300)]
lib-http: Optimized http_client_request_send_payload() fix
Badly copy&pasted my original fix, instead of noticing that Stephan's fix
was slightly different. Probably shouldn't have made actual difference
other than for performance.
Timo Sirainen [Mon, 21 Sep 2015 21:55:15 +0000 (00:55 +0300)]
lib-http: Avoid crashes on failing http_client_request_send_payload() calls
It HTTP server connection died, ioloop might not have anything to do
anymore:
Phil Carmody [Mon, 21 Sep 2015 16:52:32 +0000 (19:52 +0300)]
lib: timings - added quantiles
Just sub-sample the stream. On the assumption that the samples come from
one distribution, then any randomly selected subset will share the same
distribution. Therefore the quantiles should be at approximately the same
value.
However, that's a big assumption, as there will almost certainly be time
dependency, and periodicity (24hrs, 7 days).
Phil Carmody [Mon, 21 Sep 2015 16:51:05 +0000 (19:51 +0300)]
lib: extract sort-helpers into separate sort.h file
The macro definition was nothing to do with strings, and we can put
trivial common-type comparators here. They didn't need to be static
inline, as they can never be inlined anyway, being only used via
function pointers, but that preserves the closest equivalent to
the current code.
Timo Sirainen [Mon, 21 Sep 2015 13:36:05 +0000 (16:36 +0300)]
quota: Added "count" backend, which simply sums up mailboxes' vsizes.
In a way this is similar to the simple "dirsize" backend, but much more
efficient. As long as mailbox_list_index=yes, the quota can typically be
looked up only by reading the dovecot.list.index* files.
This backend enforces using quota_vsizes=yes setting to keep the performance
good, because physical sizes don't have a similar optimized vsize header.
There's also no especially good reason why this backend should support
physical sizes - they were originally mainly used to allow quickly stat()ing
Maildir files.
Timo Sirainen [Mon, 21 Sep 2015 13:32:27 +0000 (16:32 +0300)]
lib-storage: Update mailbox vsize header on save/copy/expunge.
This allows always efficiently looking up maiboxes' vsizes after they're
initially calculated.
The expunge handling is unfortunately done currently in quota handling code,
so it works only if quota is enabled. Ideally this would be solved in v2.3
with some lib-storage core changes.
Timo Sirainen [Mon, 21 Sep 2015 13:12:43 +0000 (16:12 +0300)]
quota: Commit expunge transaction instead of rolling back.
This likely won't make much of a difference, since it should have accessed
only expunged mails. But it's a bit cleaner this way.
Timo Sirainen [Mon, 21 Sep 2015 11:02:47 +0000 (14:02 +0300)]
imap: Improved command timing information reporting.
We now report also the time we spent waiting on ioloop. Also fixed reporting
command timing information when multiple commands were running in parallel
(e.g. SEARCH + FETCH). If multiple commands are running in parallel they all
report the same ioloop wait time, because there's no easy way to know which
one of them caused the wait.
Timo Sirainen [Mon, 21 Sep 2015 10:59:22 +0000 (13:59 +0300)]
imap: When running SEARCH on "background", run it through command_exec()
Otherwise all the timing information isn't right and the pre/post hooks
weren't being called so stats counting was also wrong.
Timo Sirainen [Sun, 20 Sep 2015 19:25:11 +0000 (22:25 +0300)]
lib-index: Added mail_index_sync_have_any_expunges()
This can be used to quickly check before mail_index_sync_begin() if there
are likely to be any expunges that will be synced.
Stephan Bosch [Sun, 20 Sep 2015 18:49:51 +0000 (21:49 +0300)]
auth: The mechanisms configured using the auth_mechanisms setting were not enforced.
The login service would check whether the mechanism is supported by auth,
but auth performed no such check of its own. This means that any
implemented mechanism was accessible from a login, even though was
presumably disabled.
Timo Sirainen [Fri, 11 Sep 2015 11:02:01 +0000 (14:02 +0300)]
lib-storage: Fixed iterating attribute prefix that matched the attribute itself.
So if attribute key was "foo", iterating "foo" returned garbage because it
skipped over the trailing \0.
Phil Carmody [Tue, 8 Sep 2015 16:28:31 +0000 (19:28 +0300)]
lib: test-strnum - do not invite undetectable errors
The very numbers which could cause a broken parser to over-run, the ones we
are testing, are the ones which will be parsed as having a value similar to
'value', so check that no value was returned by using a number completely
dissimilar to that. Otherwise, there might be an accidental mis-parse that
overwrote value, but left its value the same.
Timo Sirainen [Tue, 8 Sep 2015 16:12:26 +0000 (19:12 +0300)]
lib-storage: Replaced some unlink()s with i_unlink*()s where we could.
This changes some mail_storage_set_critical() calls to i_error()s, but
because these unlink() failures don't actually fail the operation it doesn't
matter.
Timo Sirainen [Tue, 8 Sep 2015 16:11:45 +0000 (19:11 +0300)]
lib-index: Replaced some unlink()s with i_unlink*()s where we could.
This changes some mail_index_set_error() calls to i_error()s, but because
these unlink() failures don't actually fail the operation it doesn't matter.
In fact it may be even better that it doesn't overwrite the existing
index->error if it exists.
Timo Sirainen [Tue, 8 Sep 2015 15:49:00 +0000 (18:49 +0300)]
lib: Added i_unlink() and i_unlink_if_exists()
These log the error message on a failed unlink(). They also include the
source code file and line number to make it easier to find which unlink()
actually failed if the path itself doesn't already clearly identify it.
This can be especially useful if the path is (null), "" or contains some
corrupted garbage.
Timo Sirainen [Tue, 8 Sep 2015 15:45:28 +0000 (18:45 +0300)]
lib-storage: Use MAIL_ERROR_NOTPOSSIBLE if mailbox_attribute_*set() fails for read-only attribute.
MAIL_ERROR_PARAMS indicates that there was something wrong with the
parameters itself. But the caller can't know (at least with current APIs)
if it's a read-only attribute it's trying to change before actually doing it.
Timo Sirainen [Tue, 8 Sep 2015 10:41:21 +0000 (13:41 +0300)]
lib-storage: If mail_attribute_dict is set, ignore non-authority rank internal attributes.
This way dsync can still sync things like Sieve scripts, but it doesn't
attempt to sync anything that actually requires dict.
Timo Sirainen [Tue, 8 Sep 2015 10:07:59 +0000 (13:07 +0300)]
lib-charset: Fixed assert-crash with some iconv() versions.
Older glibc iconv() versions seem to skip over invalid characters, at least
with some charsets, while newer versions don't. We were assuming that the
skipping never happened, so if the invalid character was at the end of the
string we could have wrapped size to (size_t)-1 and caused a crash later on.
Timo Sirainen [Mon, 7 Sep 2015 21:07:55 +0000 (00:07 +0300)]
lib-storage: Mailbox list notifications didn't work for INBOX.
Because of some earlier optimizations that changes to INBOX aren't written
to dovecot.list.index.log file.
Timo Sirainen [Mon, 7 Sep 2015 20:55:31 +0000 (23:55 +0300)]
Mailbox list notify API changed to return multiple events at once.
This fixes some issues where a single event could actually trigger multiple
different kinds of events.
lib: Fix hang in safe_sendfile on SmartOS
The call to sendfile on SmartOS can fail with EOPNOTSUPP. This is a valid
error code and documented in the man page. This error code needs to be
handled or else dovecot will retry the sendfile call endlessly and hang.
Timo Sirainen [Mon, 7 Sep 2015 19:14:18 +0000 (22:14 +0300)]
imap: Fixed assert-crash in NOTIFY when using multiple namespaces.
I'm not sure why the original code was trying to add it to multiple
namespaces. A single mailbox name should be matching only a single
namespace (visible one at least). In any case we can't use
mail_namespace_find() with only partial namespaces-list, because it'll
assert-crash if it can't find a namespace for the mailbox.