Phil Carmody [Wed, 3 Feb 2016 16:34:13 +0000 (18:34 +0200)]
lib: bits - new fractional log-like helper
For stats gathering, where the data can have a wide range of values, you
don't necessarily need the same granularity along the full range of values.
For example, 1ms and 11ms latencies are very different, but 1.001s and
1.011s latencies are not worth distinguishing. Something logarithmic seems
more apt. Simply looking at power-of-2 sized bands (e.g. doing log2(n)),
however, is too granular, so these new helpers let you specify how fine
to (linearly) subdivide each of those bands. 1 fractional bit splits
each power of 2 band into 2 halves. 2 fractional bits splits each power
of 2 band into 4 quarters, and so on. 0 fractional bits is just log2().
Exact identification of percentiles is impossible, but it was anyway, as you
simply cannot store all the data required to calculate them. However, a mere
896 buckets will permit you to have 32 bands per power of 2, 5 fracional bits.
The above example would have buckets such as 2.432s-2.496s, and 55.3s-56.3s.
Assuming smooth distribution lets you calculate percentiles more accurately,
just assume within each bucket is a trapezial distribution. This holds even
if the distribution is multi-modal, which it will be. However, maths required.
Phil Carmody [Wed, 3 Feb 2016 15:33:05 +0000 (17:33 +0200)]
lib: array - new copy-making array iterator
Previously macros took a pointer, and that pointer was made to pointed
to each element of the array in turn. Typical use cases for things like
char* or struct* arrays were to immediately/repeatedly, dereference that
pointer.
This new iter (only one implementation done so far, more a proof of
concept) gets rid of the user-visable pointer, and performs the
dereference every time, and only when, a valid element is being
iterated over. Empty array => no assignment. No U.B.
NOTE: This cannot be done without assuming C99. It breaks the build
on compilers that old if any components that are enabled use the
macro. It strongly suggests we just need to make C99 mandatory.
If this is explicitly set to yes or no, it overrides the global auth_verbose
setting. However, auth_debug=yes overrides all of the auth_verbose settings.
Timo Sirainen [Fri, 15 Apr 2016 12:01:20 +0000 (15:01 +0300)]
lib-stats: Handle better write() to stats process failing with EAGAIN
It only means that the stats process is too busy and the FIFO is filled up.
Retrying the write later should work. We also don't want to log too much about
the same warning, so do it only once per 30 seconds.
Timo Sirainen [Wed, 6 Apr 2016 11:09:13 +0000 (14:09 +0300)]
imapc: Fixed checking of whether same IMAP command keeps crashing server.
reconnect_command_count was counting only the post-login commands, but we
were decreasing it also for pre-login commands. This caused it to shrink to
0 too early.
Timo Sirainen [Wed, 6 Apr 2016 10:52:24 +0000 (13:52 +0300)]
lib-storage: Fixed error handling for mailbox_list_iter_init_namespaces()
If iteration for the first namespace failed, we tried to copy the error
string to error_list, which was the same first namespace's list. This caused
the error string to be freed while it was being copied, so the end result
was that the error became either an empty or garbage string.
Timo Sirainen [Tue, 5 Apr 2016 17:10:53 +0000 (20:10 +0300)]
lib-storage: Changed separator between session_id_prefix and unique part to be ':'
Although '-' wasn't used by default either, it's much more likely that
custom session IDs might contain it. ':' is hopefully less likely to be used.
This allows log parsers that actually want to find out the original session's
all log lines to cut out everything after the initial ':'.
Timo Sirainen [Wed, 6 Apr 2016 19:43:52 +0000 (22:43 +0300)]
lmtp: Changed default LMTP proxy timeout to 125 seconds.
The main problem with LMTP proxy timing out too early is that it causes
duplicates if the backend actually finishes the mail delivery.
The 30 seconds is bad, because there are various timeouts in backend set
to 30 seconds also. 125 seconds is hopefully large enough to hit most of
the 2 minute timeouts and we'll have a few extra seconds left to see the
failure.
Just ignore the -R parameter for doveadm sync, unless -1 parameter is also
used. Alternatively we could also fail the command, but maybe that's
unnecessary extra work.
Aki Tuomi [Mon, 4 Apr 2016 18:05:44 +0000 (21:05 +0300)]
doveadm-http: Fix mismatch in authorization
The code advertizes X-Dovecot-API in WWW-Authenticate header, but
expects X-Doveadm-API in Authorization header. This change makes
it expect X-Dovecot-API.
Timo Sirainen [Tue, 5 Apr 2016 16:59:18 +0000 (19:59 +0300)]
imapc: If we get disconnected during SELECT/EXAMINE, retry it once.
This seems to be happening especially with dsync migrations from IMAP
servers with small timeouts. The initial dsync run opens imapc connection
early to do a LIST + SELECT the first mailbox, but then dsync may spend a
while creating all the local mailboxes before it continues using the imapc
connection.
Timo Sirainen [Wed, 30 Mar 2016 05:24:51 +0000 (08:24 +0300)]
director: Avoid a potential assert-crash after removing a director from ring.
This should fix the crash:
Panic: director: file director-connection.c: line 1926 (director_connection_init_out): assertion failed: (!host->removed)
Also moved the last_network_failure timestamp reset a bit later, since
there's no need to reset the timestamp if we're not actually connecting
to the server.
Timo Sirainen [Tue, 29 Mar 2016 12:17:29 +0000 (15:17 +0300)]
auth: Disable auth caching for passwd-file
Its caching is usually unnecessary, because the passwd-files are efficiently
in memory already. It's also problematic, because extra_fields can contain
%variables, which can be lookup-dependent. So for example if %{lport} is used
in extra_fields, it would need to be included in the cache key. But because
different variables can be used by different users' extra_fields, there's
really no good way to include all of it in the cache key.
The problem with for example "mailbox status" command is that:
- doveadm cli: argv[0] = "mailbox", argv[1] = "status"
- doveadm-server: argv[0] = "mailbox status"
So with doveadm cli we'll now instead just skip over words until argv[0]
is the last word of the command ("status").
Stephan Bosch [Thu, 24 Mar 2016 17:47:28 +0000 (02:47 +0900)]
lib-http: client: Fixed handling of stalled connections that emerge when the client ioloop hasn't run for a long time.
Inside the peer's request handler routine, the connections are verified
after the ioloop continues. If they turn out to be broken, they
self-destruct while the handler routine is active, leading to problems.
Solved by referencing the connection and retrying the connection statistics
loop when a connection is lost in the process.