dovecot-1.2: imap: Don't cancel sync if client disconnects in th...
dovecot at dovecot.org
dovecot at dovecot.org
Tue May 26 21:20:28 EEST 2009
details: http://hg.dovecot.org/dovecot-1.2/rev/60204e3f7c4d
changeset: 9094:60204e3f7c4d
user: Timo Sirainen <tss at iki.fi>
date: Tue May 26 14:20:23 2009 -0400
description:
imap: Don't cancel sync if client disconnects in the middle.
Fixes "Message count decreased" errors.
diffstat:
1 file changed, 9 insertions(+), 5 deletions(-)
src/imap/imap-sync.c | 14 +++++++++-----
diffs (51 lines):
diff -r a4bdf6d119f6 -r 60204e3f7c4d src/imap/imap-sync.c
--- a/src/imap/imap-sync.c Tue May 26 13:48:39 2009 -0400
+++ b/src/imap/imap-sync.c Tue May 26 14:20:23 2009 -0400
@@ -372,6 +372,10 @@ int imap_sync_more(struct imap_sync_cont
string_t *str;
int ret = 1;
+ /* finish syncing even when client has disconnected. otherwise our
+ internal state (ctx->messages_count) can get messed up and unless
+ we immediately stop handling all commands and syncs we could end up
+ assert-crashing. */
str = t_str_new(256);
for (;;) {
if (ctx->seq == 0) {
@@ -404,7 +408,7 @@ int imap_sync_more(struct imap_sync_cont
ret = 1;
for (; ctx->seq <= ctx->sync_rec.seq2; ctx->seq++) {
- if (ret <= 0)
+ if (ret == 0)
break;
ret = imap_sync_send_flags(ctx, str);
@@ -426,7 +430,7 @@ int imap_sync_more(struct imap_sync_cont
ctx->seq = ctx->sync_rec.seq2;
ret = 1;
for (; ctx->seq >= ctx->sync_rec.seq1; ctx->seq--) {
- if (ret <= 0)
+ if (ret == 0)
break;
str_truncate(str, 0);
@@ -452,15 +456,15 @@ int imap_sync_more(struct imap_sync_cont
ret = 1;
for (; ctx->seq <= ctx->sync_rec.seq2; ctx->seq++) {
- if (ret <= 0)
+ if (ret == 0)
break;
ret = imap_sync_send_modseq(ctx, str);
}
break;
}
- if (ret <= 0) {
- /* failure / buffer full */
+ if (ret == 0) {
+ /* buffer full */
break;
}
More information about the dovecot-cvs
mailing list