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.
if (dir->right == conn)
dir->right = NULL;
+ if (conn->users_unsorted) {
+ /* Users were received, but handshake didn't finish.
+ Finish sorting so the users won't stay in wrong order. */
+ mail_hosts_sort_users(conn->dir->mail_hosts);
+ }
+
if (conn->connect_request_to != NULL) {
director_host_unref(conn->connect_request_to);
conn->connect_request_to = NULL;