From: Timo Sirainen Date: Sun, 18 Jun 2017 21:01:17 +0000 (+0300) Subject: imap: NOTIFY - Cleanup notify watch timeout handling X-Git-Tag: 2.3.0.rc1~1396 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=906a651134bead2be605f2be6c47bd91a4cb94be;p=thirdparty%2Fdovecot%2Fcore.git imap: NOTIFY - Cleanup notify watch timeout handling It's not useful to set the timeout until all the commands are finished. --- diff --git a/src/imap/imap-notify.c b/src/imap/imap-notify.c index 37963db9bb..3c54760762 100644 --- a/src/imap/imap-notify.c +++ b/src/imap/imap-notify.c @@ -409,10 +409,8 @@ static void imap_notify_callback(struct mailbox *box, struct client *client) 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 @@ void imap_client_notify_command_freed(struct client *client) 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)