[dovecot-cvs] dovecot/src/imap imap-sync.c,1.12,1.13
cras at dovecot.org
cras at dovecot.org
Sat Oct 15 23:53:14 EEST 2005
Update of /var/lib/cvs/dovecot/src/imap
In directory talvi:/tmp/cvs-serv1053
Modified Files:
imap-sync.c
Log Message:
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..
Index: imap-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/imap/imap-sync.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- imap-sync.c 23 Jul 2005 10:13:54 -0000 1.12
+++ imap-sync.c 15 Oct 2005 20:53:12 -0000 1.13
@@ -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));
More information about the dovecot-cvs
mailing list