changeset 22312:19f52d0ede61

imap: Don't do autoexpunging when IMAP client is hibernated
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Mon, 10 Jul 2017 13:56:49 +0300
parents 25af9d4dad59
children d4f4499c2a3a
files src/imap/imap-client-hibernate.c src/imap/imap-client.c src/imap/imap-client.h
diffstat 3 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/imap/imap-client-hibernate.c	Thu Oct 20 17:45:44 2016 +0300
+++ b/src/imap/imap-client-hibernate.c	Mon Jul 10 13:56:49 2017 +0300
@@ -239,6 +239,7 @@
 		/* hide the disconnect log message, because the client didn't
 		   actually log out */
 		client->disconnected = TRUE;
+		client->hibernated = TRUE;
 		client_destroy(client, NULL);
 		*_client = NULL;
 	}
--- a/src/imap/imap-client.c	Thu Oct 20 17:45:44 2016 +0300
+++ b/src/imap/imap-client.c	Mon Jul 10 13:56:49 2017 +0300
@@ -455,9 +455,14 @@
 	   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 IMAP session for the user. */
+	   as an active IMAP session for the user.
+
+	   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. */
 	imap_refresh_proctitle();
-	mail_user_autoexpunge(client->user);
+	if (!client->hibernated)
+		mail_user_autoexpunge(client->user);
 	mail_user_unref(&client->user);
 
 	/* free the i/ostreams after mail_user_unref(), which could trigger
--- a/src/imap/imap-client.h	Thu Oct 20 17:45:44 2016 +0300
+++ b/src/imap/imap-client.h	Mon Jul 10 13:56:49 2017 +0300
@@ -213,6 +213,7 @@
 	unsigned int sync_seen_deletes:1;
 	unsigned int logged_out:1;
 	unsigned int disconnected:1;
+	unsigned int hibernated:1;
 	unsigned int destroyed:1;
 	unsigned int handling_input:1;
 	unsigned int syncing:1;