Timo Sirainen [Thu, 19 Aug 2021 10:50:04 +0000 (12:50 +0200)]
lib-storage: Make sure header parsing is deinitialized after failures
This should fix all the possible reasons for:
Panic: file index-mail-headers.c: line 198 (index_mail_parse_header_init): assertion failed: (!mail->data.header_parser_initialized)
Timo Sirainen [Thu, 19 Aug 2021 10:32:45 +0000 (12:32 +0200)]
lib-storage: Fix potential assert-crash if filter-stream fails
If filter-stream isn't read until header (because the parent istream fails),
the header parsing isn't deinitialized. If after the failure the headers are
attempted to be parsed again, there's an assert-crash. Make sure this won't
happen by finishing the filter-istream read, and if that fails then reset the
header parsing anyway.
Destroying the filter_stream may also change the parent istream offset to
change, so this commit adds an extra seek to beginning of the istream when
beginning to parse the mail headers.
Fixes:
Panic: file index-mail-headers.c: line 198 (index_mail_parse_header_init): assertion failed: (!mail->data.header_parser_initialized)
Timo Sirainen [Wed, 18 Aug 2021 12:04:53 +0000 (14:04 +0200)]
lib-storage: Fix assert-crash in special partial mail parsing failures
This happened for example if:
- mail_precache() started parsing mail
- header was parsed, but mail body parsing failed due to mail size mismatch
- vsize parsing doesn't restart header parsing, because header size is already known
- body parsing assert-crashes because there is no messsage parser initialized
Timo Sirainen [Tue, 24 Aug 2021 20:58:59 +0000 (22:58 +0200)]
lib-test: Fix race when subprocess immediately receives signal
Signal could be received before test_subprocess_is_child=1 is set, causing
the subprocess's signal handler to also attempt to cleanup other
subprocesses.
This was causing http-test-client-errors unit tests to fail somewhat
randomly, especially when running them only with 1 CPU.
Stephan Bosch [Tue, 13 Apr 2021 16:25:06 +0000 (18:25 +0200)]
lib-smtp: smtp-server-cmd-rcpt - Fix assert crash occurring for pipelined MAIL RCPT MAIL sequence.
The assertion is wrong in that it assumes that no MAIL commands can be pending
once RCPT command is next to reply. The RCPT command does not block the
pipeline, so that a subsequent MAIL command can also be pending (but will almost
never succeed).
Reading assert-crashed if the header was read only partially. Either
because the file really was truncated or because parent stream already
had fewer bytes buffered.
Siavash Tavakoli [Fri, 25 Jun 2021 13:11:52 +0000 (14:11 +0100)]
dict: Add caching mechanism for initializing dicts
Add a pool for dict instances. Each dict is refcounted and given a grace period
of 30 seconds for deletion. If refcount drops to 0 and no new dict
operation uses the instance in that period, it will be freed. A maximum
of 10 dicts are kept in the cache.
Timo Sirainen [Tue, 27 Apr 2021 23:01:14 +0000 (02:01 +0300)]
lib-index: Fix "Extension introduction for unknown id" errors after map is generated
This happens when:
* View is opened
* Messages are expunged
* View is synced with NOEXPUNGES flag
* A new extension is introduced
* Index is rotated at least twice
* View is again synced with NOEXPUNGES flag
* More changes are done to index with the new extension
* Once more view is synced with NOEXPUNGES flag
The last sync will see changes with the new extension ID, but the view's map
doesn't know its ID.
virtual: Expunge old emails if backend box guid changed
This introduces a new extensible "ext2" header to make it easier to add new
fields in the future. It also allows keeping backwards/forwards
compatibility with the old code, so the virtual index isn't rebuilt on
upgrades or downgrades.
Timo Sirainen [Tue, 3 Aug 2021 16:47:54 +0000 (19:47 +0300)]
imap, pop3: Prevent reading ssl_ca setting into memory
Especially with imap there can be a lot of processes and a large ssl_ca
could be wasting a lot of memory. This was already the old behavior before
removing ssl_* settings from lib-storage.
MAIL_INDEX_MAIL_FLAG_UPDATE_MODSEQ flag updates didn't calculate the
returned modseq correctly. This function wasn't used outside
--with-devel-checks though, but with it this fixes:
Timo Sirainen [Thu, 5 Aug 2021 14:53:58 +0000 (17:53 +0300)]
master: Avoid high CPU usage when process_min_avail reaches process_limit
process_min_avail handling always created a 0ms timeout to try to create the
missing processes. This timeout was supposed to stop when it couldn't launch
all the wanted processes, but the check wasn't done right. This ended up
causing the timeout to be called rapidly over and over again.
Timo Sirainen [Wed, 4 Aug 2021 16:52:14 +0000 (19:52 +0300)]
lib: ioloop - Handle "time moved forwards" only after 100ms difference
Previously this was done after even a single microsecond difference,
causing it to happen almost constantly. This was causing performance
problems when there were many timeouts that had to be updated. Especially
master process could have been spending a lot of time unnecessarily here.