dovecot: Disconnect client if UIDVALIDITY changes.

dovecot at dovecot.org dovecot at dovecot.org
Sun Jul 1 01:05:50 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/064aa8ff69c2
changeset: 5848:064aa8ff69c2
user:      Timo Sirainen <tss at iki.fi>
date:      Sun Jul 01 01:04:57 2007 +0300
description:
Disconnect client if UIDVALIDITY changes.

diffstat:

3 files changed, 8 insertions(+), 2 deletions(-)
src/imap/client.h     |    2 +-
src/imap/cmd-select.c |    1 +
src/imap/imap-sync.c  |    7 ++++++-

diffs (47 lines):

diff -r 55699bbeaec2 -r 064aa8ff69c2 src/imap/client.h
--- a/src/imap/client.h	Sat Jun 30 23:01:52 2007 +0300
+++ b/src/imap/client.h	Sun Jul 01 01:04:57 2007 +0300
@@ -47,7 +47,7 @@ struct client {
 	struct mailbox *mailbox;
         struct mailbox_keywords keywords;
 	unsigned int select_counter; /* increased when mailbox is changed */
-	uint32_t messages_count, recent_count;
+	uint32_t messages_count, recent_count, uidvalidity;
 
 	time_t last_input, last_output;
 	unsigned int bad_counter;
diff -r 55699bbeaec2 -r 064aa8ff69c2 src/imap/cmd-select.c
--- a/src/imap/cmd-select.c	Sat Jun 30 23:01:52 2007 +0300
+++ b/src/imap/cmd-select.c	Sun Jul 01 01:04:57 2007 +0300
@@ -54,6 +54,7 @@ bool _cmd_select_full(struct client_comm
 	client_save_keywords(&client->keywords, status.keywords);
 	client->messages_count = status.messages;
 	client->recent_count = status.recent;
+	client->uidvalidity = status.uidvalidity;
 
 	/* set client's mailbox only after getting status to make sure
 	   we're not sending any expunge/exists replies too early to client */
diff -r 55699bbeaec2 -r 064aa8ff69c2 src/imap/imap-sync.c
--- a/src/imap/imap-sync.c	Sat Jun 30 23:01:52 2007 +0300
+++ b/src/imap/imap-sync.c	Sun Jul 01 01:04:57 2007 +0300
@@ -65,7 +65,7 @@ int imap_sync_deinit(struct imap_sync_co
 
 	mail_free(&ctx->mail);
 
-	if (mailbox_sync_deinit(&ctx->sync_ctx,
+	if (mailbox_sync_deinit(&ctx->sync_ctx, STATUS_UIDVALIDITY |
 				STATUS_MESSAGES | STATUS_RECENT, &status) < 0 ||
 	    ctx->failed) {
 		mailbox_transaction_rollback(&ctx->t);
@@ -77,6 +77,11 @@ int imap_sync_deinit(struct imap_sync_co
 
 	t_push();
 
+	if (status.uidvalidity != ctx->client->uidvalidity) {
+		/* most clients would get confused by this. disconnect them. */
+		client_disconnect_with_error(ctx->client,
+					     "Mailbox UIDVALIDITY changed");
+	}
 	if (!ctx->no_newmail) {
 		ctx->client->messages_count = status.messages;
 		if (status.messages != ctx->messages_count) {


More information about the dovecot-cvs mailing list