Timo Sirainen [Sat, 25 Nov 2017 08:01:31 +0000 (10:01 +0200)]
director: Don't send USERs in handshake that were already sent between handshake
If the user was refreshed since the handshake was started, it means that
the same user was already sent to the other side (added to the stream
immediately after it was received/handled). There's no need to send it
again.
This fixes a potentally infinite handshake when users are rapidly changing
and the handshake iterator never sees the end of the list. (Each refreshed
user is moved to the end of the list, so handshaking can keep sending the
same user over and over again.)
Timo Sirainen [Sat, 25 Nov 2017 08:05:27 +0000 (10:05 +0200)]
director: Delay sorting users until there are no more user iterators
This shouldn't have normally happened. Only when an outgoing handshake was
going on at the same time as a) another outgoing handshake was going on, or
b) doveadm was doing HOST-RESET-USERS
Timo Sirainen [Sat, 25 Nov 2017 23:31:08 +0000 (01:31 +0200)]
director: Avoid USER loops with >1s ring latency also with old directors
Do this by ignoring USER refreshes that were already updated recently.
The "recently" is calculated by director_user_expire/4 seconds ago, but
with an upper limit of 15 secs. This means that the USER loops can now
only exist if the director ring latency is above 15 seconds. (Once all
directors in the ring are running the new version, there's no looping
at any latency.)
Timo Sirainen [Sat, 25 Nov 2017 23:19:35 +0000 (01:19 +0200)]
director: Avoid USER loops when ring latency is over 1 second
Do this by adding a timestamp parameter to USER events. This way if it
takes over 1 second for the USER event to traverse the ring, it won't get
into an infinite loop getting the user updated over and over again.
Timo Sirainen [Fri, 17 Nov 2017 11:24:59 +0000 (13:24 +0200)]
director: Keep users unsorted during handshake and sort them at the end
This is simpler and sometimes more efficient than the current way of
immediately inserting the users to the correct place in the linked list.
This is especially useful if handshaking is mixed with regular USER updates,
because each switch between them required walking the linked list backwards
to find the proper insert position.
It's not a big problem if the users list is temporarily unordered. It mainly
means that some of the users won't be expired as early as they should have.
Timo Sirainen [Fri, 17 Nov 2017 16:53:18 +0000 (18:53 +0200)]
director: Make sure users are sorted after unfinished handshake
The users were sorted after the handshake was finished, but if the
connection was closed before that hapepned, the users were left
unsorted. This could have caused the users to not expire early
enough.
Timo Sirainen [Fri, 24 Nov 2017 10:31:22 +0000 (12:31 +0200)]
lib-storage: Fix sorting mails with the same primary sort key
The sorting order may have been wrong when there was a combination of:
* Messages were sorted by a string (e.g. Subject)
* Some messages had the same sort key (e.g. same base subject)
* Within the messages with the same sort key, some of the messages already
had the "sort-*" index number in Dovecot indexes, but some of them
didn't.
The result was that Dovecot found that the two messages had exactly the same
sort key. It should have continued with the secondary sort key (e.g.
message sequence number), but it didn't.
Timo Sirainen [Sat, 18 Nov 2017 21:10:47 +0000 (23:10 +0200)]
lib-storage: Make sure mailbox autocreation doesn't get into infinite loop
If mailbox_create() -> mailbox_open() fails with MAIL_ERROR_NOTFOUND, it
would have looped back to mailbox_create() and continued this until
running out of stack.
Timo Sirainen [Wed, 15 Nov 2017 22:44:17 +0000 (00:44 +0200)]
director: Reconnect after detecting a write failure to director
If disconnection is detected during write failure, or "Output buffer full"
occurs, the connection is disconnected. However, if this was the right side
connection, it wasn't automatically reconnected to. This left the ring
nonworking.
Timo Sirainen [Wed, 15 Nov 2017 13:53:03 +0000 (15:53 +0200)]
lib-imap: imap_envelope_parse() - remove unnecessary data stack frame
imap_envelope_parse_args() isn't using data stack at all, so this
unnecessarily complicates the code. It also prevents using datastack-pool
as the pool parameter.
lib-master: Drop support for SSL_TXT_SSLV2 in master-service-ssl-settings.c
OpenSSL headers are not included in master-service-ssl-settings.c, so
the check for SSL_TXT_SSLV2 is broken at the moment, and the feature is
not worth supporting since SSLv2 is obsolete.
Timo Sirainen [Tue, 14 Nov 2017 14:51:37 +0000 (16:51 +0200)]
auth: Remove userdb nss
Its original purpose was because getpwnam() couldn't differentiate between
"user doesn't exist" and "temporary error", but this was solved by using
getpwnam_r() instead.
So all userdb nss users should be able to safely switch to userdb passwd.
With recent solr versions (7.0+) the default response
writer changed from XML to JSON. This commit sets the
"wt" query parameter for all requests, so that the right
response type is written.