Don't autoexpunge if the client is hibernated - it shouldn't be any
different from the non-hibernating IDLE case. For frequent
- hibernations it could also be doing unnecessarily much work. */
+ hibernations it could also be doing unnecessarily much work.
+
+ Don't perform autoexpunging if whole Dovecot is shutting down. This
+ could lead to a load spike and unnecessarily slowing down the
+ shutdown process. Also don't do this when processes are being
+ killed, for similar reasoning. */
imap_refresh_proctitle();
if (!client->hibernated) {
- client->logout_stats.autoexpunged_count = mail_user_autoexpunge(client->user);
+ if (!master_service_is_killed(master_service) &&
+ !master_service_is_master_stopped(master_service)) {
+ client->logout_stats.autoexpunged_count =
+ mail_user_autoexpunge(client->user);
+ }
client_log_disconnect(client, reason);
}
mail_user_deinit(&client->user);
before it starts, and refresh proctitle so it's clear that it's
doing autoexpunging. We've also sent DISCONNECT to anvil already,
because this is background work and shouldn't really be counted
- as an active POP3 session for the user. */
+ as an active POP3 session for the user.
+
+ Don't perform autoexpunging at shutdown to avoid load spikes. See
+ imap code for more detailed reasoning. Although this is less of an
+ issue with POP3 since the sessions are so short-lived. */
pop3_refresh_proctitle();
- mail_user_autoexpunge(client->user);
+ if (!master_service_is_killed(master_service) &&
+ !master_service_is_master_stopped(master_service))
+ mail_user_autoexpunge(client->user);
mail_user_deinit(&client->user);
settings_free(client->set);
settings_free(client->mail_set);