changeset 22246:0eb4d3b9b0a9

imap: NOTIFY - Cleanup notify watch timeout handling It's not useful to set the timeout until all the commands are finished.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Mon, 19 Jun 2017 00:01:17 +0300
parents 06b45ab1ae72
children 60ecab5c8e9e
files src/imap/imap-notify.c
diffstat 1 files changed, 11 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/imap/imap-notify.c	Sun Jun 18 11:14:05 2017 +0300
+++ b/src/imap/imap-notify.c	Mon Jun 19 00:01:17 2017 +0300
@@ -409,10 +409,8 @@
 
 static void imap_notify_watch_selected_mailbox(struct client *client)
 {
-	if (client->command_queue_size > 0) {
-		/* don't add it until all commands are finished */
-		return;
-	}
+	i_assert(client->command_queue_size == 0);
+
 	if (client->mailbox == NULL) {
 		/* mailbox not selected */
 		return;
@@ -439,14 +437,16 @@
 	if (ctx == NULL)
 		return;
 
-	/* add mailbox watched back after a small delay */
-	if (ctx->to_watch != NULL)
-		timeout_reset(ctx->to_watch);
-	else {
-		ctx->to_watch = timeout_add(IMAP_NOTIFY_WATCH_ADD_DELAY_MSECS,
-					    imap_notify_watch_timeout,
-					    client);
+	if (client->command_queue_size > 0) {
+		/* don't add it until all commands are finished */
+		i_assert(ctx->to_watch == NULL);
+		return;
 	}
+
+	/* add mailbox watch back after a small delay. if another command
+	   is started this timeout is aborted. */
+	ctx->to_watch = timeout_add(IMAP_NOTIFY_WATCH_ADD_DELAY_MSECS,
+				    imap_notify_watch_timeout, client);
 }
 
 void imap_client_notify_command_allocated(struct client *client)