Skip to content

Commit

Permalink
imap NOTIFY: Flush any pending notifications on NOOP
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sirainen authored and villesavolainen committed May 26, 2017
1 parent 3ee1976 commit 6c4273f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/imap/cmd-noop.c
@@ -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.");
}
10 changes: 10 additions & 0 deletions src/imap/imap-notify.c
Expand Up @@ -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);
}
}
2 changes: 2 additions & 0 deletions src/imap/imap-notify.h
Expand Up @@ -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

0 comments on commit 6c4273f

Please sign in to comment.