Timo Sirainen [Fri, 22 Jan 2021 11:19:05 +0000 (13:19 +0200)]
lib-master: test-event-stats - Fix unit test when compiling using build directory
When using build directory __FILE__ expands to
"../../../src/lib-master/test-event-stats.c", which doesn't match
"test-event-stats.c" what is normally used.
Paul Howarth [Mon, 4 Jan 2021 16:31:03 +0000 (16:31 +0000)]
lib: Fix timeval_cmp_margin for 32-bit systems
The test suite compares times with seconds values of -INT_MAX and
INT_MAX. The result of this comparison does not fit in a value of
type int and so the test suite fails on 32-bit systems where time_t
is an int. To fix this, calculations on seconds values are done
using long long integers.
Timo Sirainen [Tue, 26 Jan 2021 16:55:22 +0000 (18:55 +0200)]
dsync: Replace escape characters in outgoing mailbox names with alt_char
Especially when dsync is used for migration, we don't want to end up having
invalid mUTF7 mailbox names locally. Also, remote might not even be
configured to use the same escape character.
Timo Sirainen [Thu, 14 Jan 2021 15:45:07 +0000 (17:45 +0200)]
lib-storage: mailbox_list_default_get_storage_name() - Escape ns_prefix/INBOX if possible
If storage_name_escape_char is set, escape the "I" letter in the
storage_name if the namespace also has inbox=yes. This way it's possible to
distinguish between the actual INBOX and ns_prefix/INBOX.
Timo Sirainen [Thu, 14 Jan 2021 15:27:03 +0000 (17:27 +0200)]
lib-storage: Fix mailbox name escape/unescape ordering
This fixes some cases like not properly escaping '/' in storage_name if it
was also the namespace separator. This also allows using the same character
for both vname_escape_char and storage_name_escape_char.
Timo Sirainen [Thu, 14 Jan 2021 15:07:34 +0000 (17:07 +0200)]
lib-storage: mailbox_list_default_get_vname() - Fix escaping namespace separator in storage_name
For example if { storage_name="foo/bar", storage_sep=".", ns_sep="/" }
the "/" in the name shouldn't be treated as a namespace separator.
If vname_escape_char is set, it should be returned escaped instead.
Timo Sirainen [Thu, 14 Jan 2021 13:40:44 +0000 (15:40 +0200)]
lib-storage: mailbox_list_default_get_vname() - Use imap_utf7_to_utf8_escaped()
This changes the output a bit for broken mUTF7 names. Previously if any
part of the string had broken mUTF7 input, none of it was converted.
Now it's instead trying to convert as much as it can.
Timo Sirainen [Thu, 14 Jan 2021 10:34:48 +0000 (12:34 +0200)]
lib-storage: mailbox_list_default_get_storage_name() - Escape each hierarchical name separately
This makes it possible in the following commits to allow unescaping to
write namespace hierarchy separator character without converting it into
the mailbox_list separator.
Stephan Bosch [Sat, 18 Apr 2020 10:56:14 +0000 (12:56 +0200)]
m4: Fix configuration of libunwind on i386 (and probably other systems).
Use the standard libunwind-coredump instead of the system-dependent library.
This way, all can be configured using pkg-config, without relying on a failed
attempt to use the $build_cpu variable to find the system-dependent library.
This fails on i386 and probably other systems as well.
Timo Sirainen [Wed, 25 Mar 2020 13:52:02 +0000 (15:52 +0200)]
lib-imap: imap_arg_get/as_nstring() - fail if input is an atom
Atoms were wrongly allowed in these places.
These have been used in very few places, so this change should be pretty
safe to do. The only affected places are:
* SETMETADATA - Backwards compatibility preserved by earlier commit
* ID - It's not expected that any clients use atoms here
* imapc - Server replies are parsed more strictly now
lib: event-filter - Use p_strdup() instead of p_strdup_empty() to avoid NULLs
The code used p_strdup_empty() in an (incorrect) attempt to avoid NULLs
turning into empty strings (""). None of the strdup variants do this.
However, p_strdup_empty() converts empty strings to NULLs. This caused a
NULL pointer dereference later on.
lib: event-filter - Implement filter boolean expression unit tests
This is a exhaustive test of the boolean operators using field equality
comparisons. This test code focuses on the boolean operators (AND, OR,
NOT) and not on the comparison operators (=, <, >, <=, and >=) and their
arguments (event names, source locations, categories).
lib: event-filter - Make NOT operator right associative and higher precedence
For example, consider the filter:
event=* AND
NOT event=foo AND
NOT event=bar AND
NOT event=baz
The "NOT" operator is supposed to be bound to the comparisons to the
immediate right. That is, it supposed to be equivalent to:
event=* AND
(NOT event=foo) AND
(NOT event=bar) AND
(NOT event=baz)
Both of these should produce the following parse tree:
AND
AND
AND
EQ EVENT '*'
NOT
EQ EVENT 'foo'
NOT
EQ EVENT 'bar'
NOT
EQ EVENT 'baz'
Instead, before this commit, the NOTs were getting bound to the entire
sub-expression to the right. Therefore, the original filter expression
was being parsed as if it were:
event=* AND
NOT (event=foo AND
NOT (event=bar AND
NOT event=baz))
Which produced the following parse tree:
AND
EQ EVENT '*'
NOT
AND
EQ EVENT 'foo'
NOT
AND
EQ EVENT 'bar'
NOT
EQ EVENT 'baz'
Siavash Tavakoli [Mon, 21 Dec 2020 10:45:32 +0000 (10:45 +0000)]
indexer: Remove worker-specific request queue
- Each request is done in a single connection and indexer master disconnects
from worker after indexing job is complete.
- No need to keep a worker queue since it always have length of 1. Instead,
keep a pointer to indexer_request for each worker connection.
- If indexing is in progress for a user, don't try to use the same connection
when a new request arrives for the same user. Instead, move the request to the
back of the queue and wait for the in progress request to finish then
create a new connection and submit request to worker.
Siavash Tavakoli [Sun, 20 Dec 2020 19:45:09 +0000 (19:45 +0000)]
indexer: Cleanup idle_list from worker pool
- Indexer always disconnects from worker process, no need to keep a list
of idle processes.
- The callback already calls worker_pool_release_connection every time worker
updated percentage. Defer disconnecting from working to the callback.
It checks if the request is completed and destroys connection.
Timo Sirainen [Wed, 20 May 2020 10:42:22 +0000 (13:42 +0300)]
lib: hash - Add assert to make sure hash table doesn't grow beyond UINT_MAX nodes
hash_table_count() returns unsigned int, so the node count can't be larger.
It's internally also tracked as unsigned int currently. It should be large
enough for all practical use cases.