Mercurial > dovecot > original-hg > dovecot-1.2
changeset 6311:e84fad8d3987 HEAD
Handle initial syncing errors better.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 24 Aug 2007 19:56:40 +0300 |
parents | 15e10065a472 |
children | 05aabdc581b1 |
files | src/pop3/client.c |
diffstat | 1 files changed, 24 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/pop3/client.c Fri Aug 24 19:36:03 2007 +0300 +++ b/src/pop3/client.c Fri Aug 24 19:56:40 2007 +0300 @@ -49,7 +49,7 @@ return mailbox_sync_deinit(&ctx, STATUS_UIDVALIDITY, status); } -static int init_mailbox(struct client *client) +static bool init_mailbox(struct client *client, const char **error_r) { struct mail_search_arg search_arg; struct mailbox_transaction_context *t; @@ -57,9 +57,10 @@ struct mailbox_status status; struct mail *mail; buffer_t *message_sizes_buf; + uint32_t failed_uid = 0; uoff_t size; int i; - bool failed; + bool failed, expunged; message_sizes_buf = buffer_create_dynamic(default_pool, 512); @@ -80,10 +81,18 @@ client->total_size = 0; buffer_set_used_size(message_sizes_buf, 0); + expunged = FALSE; failed = FALSE; mail = mail_alloc(t, MAIL_FETCH_VIRTUAL_SIZE, NULL); while (mailbox_search_next(ctx, mail) > 0) { if (mail_get_virtual_size(mail, &size) < 0) { + if (failed_uid == mail->uid) { + i_error("Getting size of message " + "UID=%u failed", mail->uid); + break; + } + failed_uid = mail->uid; + expunged = mail->expunged; failed = TRUE; break; } @@ -98,7 +107,7 @@ message_sizes_buf->used / sizeof(uoff_t); mail_free(&mail); - if (mailbox_search_deinit(&ctx) < 0) { + if (mailbox_search_deinit(&ctx) < 0 || (failed && !expunged)) { client_send_storage_error(client); (void)mailbox_transaction_commit(&t, 0); break; @@ -116,8 +125,16 @@ (void)mailbox_transaction_commit(&t, 0); } - if (i == 2) - client_send_line(client, "-ERR [IN-USE] Couldn't sync mailbox."); + if (expunged) { + client_send_line(client, + "-ERR [IN-USE] Couldn't sync mailbox."); + *error_r = "Can't sync mailbox: Messages keep getting expunged"; + } else { + struct mail_storage *storage = client->inbox_ns->storage; + enum mail_error error; + + *error_r = mail_storage_get_last_error(storage, &error); + } buffer_free(message_sizes_buf); return FALSE; } @@ -174,9 +191,8 @@ return NULL; } - if (!init_mailbox(client)) { - i_error("Couldn't init INBOX: %s", - mail_storage_get_last_error(storage, &error)); + if (!init_mailbox(client, &errmsg)) { + i_error("Couldn't init INBOX: %s", errmsg); client_destroy(client, "Mailbox init failed"); return NULL; }