Mercurial > dovecot > original-hg > dovecot-1.2
changeset 3652:440137d72ca0 HEAD
When output buffer got full while sending syncing changes, we sent the last
change twice to client. This was bad if extra EXPUNGEs got sent..
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 15 Oct 2005 23:53:12 +0300 |
parents | a2d7da8ad64e |
children | d408296d9a5d |
files | src/imap/imap-sync.c |
diffstat | 1 files changed, 19 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/imap/imap-sync.c Sat Oct 15 23:11:27 2005 +0300 +++ b/src/imap/imap-sync.c Sat Oct 15 23:53:12 2005 +0300 @@ -117,7 +117,11 @@ if (ctx->seq == 0) ctx->seq = ctx->sync_rec.seq1; + ret = 1; for (; ctx->seq <= ctx->sync_rec.seq2; ctx->seq++) { + if (ret <= 0) + break; + if (mail_set_seq(ctx->mail, ctx->seq) < 0) { t_pop(); return -1; @@ -131,11 +135,8 @@ ctx->seq); imap_write_flags(str, flags, keywords); str_append(str, "))"); + ret = client_send_line(ctx->client, str_c(str)); - if (ret <= 0) { - t_pop(); - return ret; - } } break; case MAILBOX_SYNC_TYPE_EXPUNGE: @@ -145,17 +146,22 @@ ctx->sync_rec.seq2 - ctx->sync_rec.seq1 + 1; } + ret = 1; for (; ctx->seq >= ctx->sync_rec.seq1; ctx->seq--) { + if (ret <= 0) + break; + str_truncate(str, 0); str_printfa(str, "* %u EXPUNGE", ctx->seq); ret = client_send_line(ctx->client, str_c(str)); - if (ret <= 0) { - t_pop(); - return ret; - } } break; } + if (ret <= 0) { + /* failure / buffer full */ + break; + } + ctx->seq = 0; } t_pop(); @@ -177,10 +183,14 @@ static int cmd_sync_continue(struct client_command_context *cmd) { struct cmd_sync_context *ctx = cmd->context; + int ret; - if (imap_sync_more(ctx->sync_ctx) == 0) + if ((ret = imap_sync_more(ctx->sync_ctx)) == 0) return FALSE; + if (ret < 0) + ctx->sync_ctx->failed = TRUE; + if (imap_sync_deinit(ctx->sync_ctx) < 0) { client_send_untagged_storage_error(cmd->client, mailbox_get_storage(cmd->client->mailbox));