Timo Sirainen [Mon, 13 Oct 2014 15:50:44 +0000 (08:50 -0700)]
lib-index: Automatically grow header size on header updates.
This fixes assert-crashes when it didn't happen.
For example an old Maildir index could have had a header size 24. Dovecot
crashed then when trying to update it, because the new header size is 36 and
there wasn't an explicit mail_index_ext_resize_hdr() call.
Stephan Bosch [Fri, 10 Oct 2014 21:43:38 +0000 (00:43 +0300)]
lib-dns: The dns_lookup() call caused a crash upon a connect error, because dns_client_disconnect() can indirectly call itself recursively.
Solved by dropping the list of lookups from the client object before the
lookups are destroyed.
Timo Sirainen [Fri, 10 Oct 2014 15:11:58 +0000 (18:11 +0300)]
maildir: Don't limit uidlist line lengths to 4096 bytes.
Although this always indicates corruption, the current code doesn't handle
that very nicely. One fix would be to just ignore such long lines, but this
is easier to implement..
Stephan Bosch [Thu, 9 Oct 2014 21:46:15 +0000 (00:46 +0300)]
lib-http: client: Fixed assert crash occurring when DNS lookup fails immediately during request submission.
In that situation, the request was not dropped from the queue immediately, triggering the assert crash.
Timo Sirainen [Thu, 9 Oct 2014 15:23:41 +0000 (18:23 +0300)]
lib-index: Replaced some automatic transaction log unlocks with asserts.
Some earlier Dovecot versions were read-locking transaction logs and this
was useful there. But now we only do exclusive locking for the log head, so
it's an error not to explicitly unlock the files.
Timo Sirainen [Thu, 9 Oct 2014 15:19:11 +0000 (18:19 +0300)]
maildir: Use MAIL_TRANSACTION_LOG_LOCK_WARN_SECS as threshold for logging a "long sync" warning.
This is because the index syncing keeps the log locked, and other processes
trying to lock the log will start logging warnings as well.
Timo Sirainen [Thu, 9 Oct 2014 15:14:43 +0000 (18:14 +0300)]
lib: o_stream_send_istream() shouldn't ignore EINTRs for file ostreams.
Also added extra asserts to make sure that either we return an error or we
write everything from input stream to output stream. This should make it
safe to write to files using just:
if (o_stream_send_istream(ostream, istream) < 0) {
// failed
} else {
// everything in istream was written to ostream
}
Timo Sirainen [Thu, 9 Oct 2014 13:42:01 +0000 (16:42 +0300)]
lib-storage: If uncached header unfolding fails, panic instead of returning error.
This really shouldn't be happening. This also makes it clear that return
value -1 means some kind of I/O error instead of corruption.
Timo Sirainen [Thu, 9 Oct 2014 13:41:23 +0000 (16:41 +0300)]
lib-storage: Fixed header parsing when there were multiple same header names.
For example if a mail had:
Name1: a
Name1: b
Name2: c
If the Name1: was initially added to cache and Name2: not, but later on both
were attempted to be added to cache, the Name2: lookup would have been added
with "b" instead of "c" value.
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.