]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap NOTIFY: Flush any pending notifications on NOOP
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 17 May 2017 16:02:06 +0000 (19:02 +0300)
committerGitLab <gitlab@git.dovecot.net>
Fri, 19 May 2017 14:19:52 +0000 (17:19 +0300)
This is mainly to allow testing NOTIFY easily with imaptest scripts.
This is cheap anyway, because mailbox_list_notify_flush() doesn't do any
syscalls when there's no work.

src/imap/cmd-noop.c
src/imap/imap-notify.c
src/imap/imap-notify.h

index af273b528c58915bc921b0cd055ad7250810ec14..01d5c8c25fb96e11f9f5452f32fc2a9c1d9caa6e 100644 (file)
@@ -1,9 +1,15 @@
 /* Copyright (c) 2002-2017 Dovecot authors, see the included COPYING file */
 
 #include "imap-common.h"
+#include "imap-notify.h"
 #include "imap-commands.h"
 
 bool cmd_noop(struct client_command_context *cmd)
 {
+       if (cmd->client->notify_ctx != NULL) {
+               /* flush any delayed notifications now. this is mainly useful
+                  for testing. */
+               imap_notify_flush(cmd->client->notify_ctx);
+       }
        return cmd_sync(cmd, 0, IMAP_SYNC_FLAG_SAFE, "OK NOOP completed.");
 }
index c2020166db15cfd7b7e58f5dc695424c76e1071f..88de0f47bf7d8e423ece07a6232fe37b268f1b1f 100644 (file)
@@ -522,3 +522,13 @@ void imap_notify_deinit(struct imap_notify_context **_ctx)
                imap_fetch_free(&ctx->fetch_ctx);
        pool_unref(&ctx->pool);
 }
+
+void imap_notify_flush(struct imap_notify_context *ctx)
+{
+       struct imap_notify_namespace *notify_ns;
+
+       array_foreach_modifiable(&ctx->namespaces, notify_ns) {
+               if (notify_ns->notify != NULL)
+                       mailbox_list_notify_flush(notify_ns->notify);
+       }
+}
index 6d8990df0e56a7a1a4e7612444dbae3fd9f7296a..e917624406ddeeedd19773e98d00a6635c96770a 100644 (file)
@@ -69,4 +69,6 @@ void imap_client_notify_command_freed(struct client *client);
 int imap_notify_begin(struct imap_notify_context *ctx);
 void imap_notify_deinit(struct imap_notify_context **ctx);
 
+void imap_notify_flush(struct imap_notify_context *ctx);
+
 #endif