Timo Sirainen [Tue, 7 Oct 2014 17:13:36 +0000 (20:13 +0300)]
lib-index: Fixed assert-crash in some cache locking race conditions.
If mail_index_map() is being called, we can't refresh the index or it'll
crash. It wouldn't help anyway, since the index was just refreshed.
Timo Sirainen [Tue, 7 Oct 2014 16:07:16 +0000 (19:07 +0300)]
lib-index: Delay unlocking cache compression until changes to transaction log are committed.
This should fix race condition with two processes compressing the file at
the same time with same file_seq and becoming confused.
Timo Sirainen [Tue, 7 Oct 2014 16:04:36 +0000 (19:04 +0300)]
lib-index: Added path parameter to mail_index_create_tmp_file()
This allows using it for creating any kind of a new index file with proper
file permissions.
Some of the old code should probably be changed to use this. Maybe even move
this function to public mail-index.h
Timo Sirainen [Tue, 7 Oct 2014 15:58:01 +0000 (18:58 +0300)]
lib-index: Try to minimize race conditions while compressing cache.
There are some unavoidable race conditions, but try to keep their time
window as small as possible.
Timo Sirainen [Tue, 7 Oct 2014 15:47:09 +0000 (18:47 +0300)]
lib-index: mail_cache_lock() partial rewrite.
require_same_reset_id is no longer needed, if it ever was. If we're locking
the cache file, we always want the latest one. The logic of locking in
general was somewhat confusing and it probably didn't always successfully
lock when it should have, because the reset_id happened to match an old
file.
Timo Sirainen [Mon, 6 Oct 2014 23:35:41 +0000 (02:35 +0300)]
lib-index: Fixed cache file creation race condition.
If two processes are creating the index files at the same time, don't have
one of them delete the dovecot.index.cache that the other one just created.
This means we never should be calling mail_cache_create(), so it was removed
entirely.
Timo Sirainen [Mon, 6 Oct 2014 23:33:03 +0000 (02:33 +0300)]
lib-index: Don't keep cache file locked for as long while syncing index.
The earlier code was required for updating the cache offsets, but this code
no longer exists. Now we just need to update the record counts in the
header, which can be done quickly at the end of the sync.
Timo Sirainen [Mon, 6 Oct 2014 09:21:24 +0000 (12:21 +0300)]
doveadm backup: When deleting a mailbox, log a warning, not just a debug message.
Because we're also returning temporary failure in any case, so there needs
to be some kind of a warning/error logged.
Stephan Bosch [Sat, 4 Oct 2014 14:32:48 +0000 (17:32 +0300)]
lib-http: Fixed detecting disconnection when ioloop is running only intermittently.
This fix only applies to ioloops created and run by lib-http itself.
Stephan Bosch [Sat, 4 Oct 2014 14:31:38 +0000 (17:31 +0300)]
lib: Fixed io_loop_move_timeout() to retain the next_run time, so that the timeout is not implicitly reset.
This problem became with timeout_add_absolute(), since resetting an
absolute timeout causes it to fire immediately (msecs == 0).
Stephan Bosch [Sat, 4 Oct 2014 14:30:54 +0000 (17:30 +0300)]
lib-http: client: Fixed problem occuring when a nested ioloop was run inside a request callback using the same client.
If requests in the nested ioloop would use the same connection as the one
that called the callback, the requests would (in the best scenario) all be
doomed to time out.
Timo Sirainen [Fri, 3 Oct 2014 13:31:33 +0000 (16:31 +0300)]
lib-lda, lmtp: Separate internal errors from remote errors.
LMTP proxy shouldn't log remote errors with error level, because the proxy
itself didn't have any failure.
This is an API change, but I'm not aware of any plugins actually using the
lmtp-client.h directly.
Timo Sirainen [Fri, 3 Oct 2014 13:04:06 +0000 (16:04 +0300)]
master: If log process crashes, restart it immediately.
The regular service_monitor_listen_start() doesn't work for it, because the
log fds aren't in the listeners.
Stephan Bosch [Wed, 1 Oct 2014 07:33:49 +0000 (10:33 +0300)]
lib-http: client: Fixed recovery after connection failure.
If a parallel already connected connection was active, the queue wasn't notified of the failure.
Only pending connections should be considered in this case and not established ones.
Stephan Bosch [Wed, 1 Oct 2014 07:33:39 +0000 (10:33 +0300)]
lib-http: client: Fixed aborting request in the middle of sending payload.
If the request payload is so big that it cannot be sent all at once, the
caller may at some point abort the request when it is still being sent. The
bug occurred when the request finally finished sending. It erroneously
advanced the state to WAITING rather than remaining ABORTED, thus
'reviving' the request unexpectedly.
Stephan Bosch [Tue, 30 Sep 2014 20:49:52 +0000 (23:49 +0300)]
lib-http: client: The http_client_queue_fail() function aborted requests in an unsafe manner.
Copied queues before freeing the requests, because the destroyed requests modify the queue.
Timo Sirainen [Thu, 25 Sep 2014 21:32:03 +0000 (00:32 +0300)]
lib-storage: Don't assume that we must read the whole message to get its virtual size.
This is true only with mbox format. All the other formats have various
metadata available where it's stored.
Timo Sirainen [Thu, 25 Sep 2014 16:43:28 +0000 (19:43 +0300)]
imap: die-callback didn't set log prefixes correctly for client handlers
Calling mail_storage_service_io_activate_user() unfortunately doesn't set
the ioloop context itself, so timeouts weren't inheriting it. It seemed a
bit difficult to change this, so for now I just moved the call to the
timeout handler.
Timo Sirainen [Thu, 25 Sep 2014 12:50:03 +0000 (15:50 +0300)]
lib: If file_wait_lock*() fails, try to include the current pid holding the lock in error message.
This is currently supported via fcntl(F_GETLK) and also via Linux
/proc/locks.
Timo Sirainen [Wed, 24 Sep 2014 22:13:12 +0000 (01:13 +0300)]
lib-storage: Added mailbox_get_index_path() and caching of the index path.
This solves some potential assert-crashes on race conditions when opening a
mailbox while it's being deleted.
Timo Sirainen [Wed, 24 Sep 2014 21:42:56 +0000 (00:42 +0300)]
lib-storage: Headers were sometimes added to dovecot.index.cache with wrong line number value.
This happened if the header parsing was done multiple times for the same
mail. The end result being that when fetching multiple headers as a stream,
the headers could have been returned in the wrong order. This messed up at
least dsync's header hash comparisons.
Timo Sirainen [Tue, 23 Sep 2014 13:58:59 +0000 (16:58 +0300)]
imap: Don't send MODSEQ in untagged FETCH reply if IMAP client didn't enable CONDSTORE/QRESYNC.
We should have been checking client->enabled_features, not
mailbox_get_enabled_features(). The former contains the features enabled by
the IMAP client, while the latter contains also some automatically added
features.
Timo Sirainen [Mon, 22 Sep 2014 13:08:25 +0000 (16:08 +0300)]
lib-master: Increased instances file's dotlock timeout to 2 seconds.
The 1 second would have been enough, except the current dotlocking code
uses second-level precision in checking timeouts, so it could end up trying
the lock only once.
A better fix would be to fix the dotlocking code to use millisecond-level
precision (internally), but since this is the only user so far where it
would have mattered, it's not really worth the effort (yet).
Phil Carmody [Mon, 22 Sep 2014 12:56:31 +0000 (15:56 +0300)]
lib: bsearch - make BINARY_NUMBER_SEARCH more widely usable
This template is more widely usable if we do not hard-code into it the
method of accessing the value being compared. For the default case
we already use, this accessor is just a simple array dereferencing
macro.
As rewriting with the array access happens in the preprocessor, the
code generated is completely unchanged.
Timo Sirainen [Tue, 16 Sep 2014 20:22:59 +0000 (23:22 +0300)]
virtual: Using modseq-based syncing while mailbox was open didn't handle expunges correctly.
The expunges were handled only after EXPUNGE command was given, which should
have been done only for mails that no longer matched the search query but
still existed.
Timo Sirainen [Tue, 16 Sep 2014 17:59:48 +0000 (20:59 +0300)]
quota: Quota recalculation didn't include INBOX in some configurations.
If one inbox=yes and another inbox=no namespace shared the same mail
location, and the inbox=no namespace was first, only it was used to list all
mailboxes.
Timo Sirainen [Tue, 16 Sep 2014 12:43:42 +0000 (15:43 +0300)]
lib-storage: SEARCH_MAILBOX* value is now also compared to to the (virtual) mailbox name.
This fixes for example "doveadm fetch uid mailbox virtual/all"
Phil Carmody [Tue, 16 Sep 2014 10:38:30 +0000 (13:38 +0300)]
lib: test-strnum - add size-oblivious str_to/parse_uintmax tests
Test a value of every bit-length. Also test the 10/9*MAX corner case.
And due to crappy helper functions, test lots of leading zeroes too!