]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: If INBOX can't be opened/synced, log an error once.
authorTimo Sirainen <tss@iki.fi>
Sat, 27 Mar 2010 03:01:17 +0000 (05:01 +0200)
committerTimo Sirainen <tss@iki.fi>
Sat, 27 Mar 2010 03:01:17 +0000 (05:01 +0200)
--HG--
branch : HEAD

src/lib-storage/mail-storage.c
src/lib-storage/mail-user.h

index 7d99b9e5cc1aad90220a685f1e9b75c98eecb820..1f5dbeb8ee4851980871033701b04586cc30cdce 100644 (file)
@@ -538,6 +538,11 @@ static int mailbox_open_full(struct mailbox *box, struct istream *input)
                (void)mailbox_create(box, NULL, FALSE);
                mailbox_close(box);
                ret = box->v.open(box);
+               if (ret < 0 && !box->storage->user->inbox_open_error_logged) {
+                       box->storage->user->inbox_open_error_logged = TRUE;
+                       i_error("Opening INBOX failed: %s",
+                               mail_storage_get_last_error(box->storage, NULL));
+               }
        } T_END;
 
        if (ret < 0) {
@@ -860,11 +865,24 @@ int mailbox_sync_deinit(struct mailbox_sync_context **_ctx,
                        struct mailbox_sync_status *status_r)
 {
        struct mailbox_sync_context *ctx = *_ctx;
+       struct mail_storage *storage = ctx->box->storage;
+       const char *errormsg;
+       enum mail_error error;
+       int ret;
 
        *_ctx = NULL;
 
        memset(status_r, 0, sizeof(*status_r));
-       return ctx->box->v.sync_deinit(ctx, status_r);
+       ret = ctx->box->v.sync_deinit(ctx, status_r);
+       if (ret < 0 && ctx->box->inbox &&
+           !storage->user->inbox_open_error_logged) {
+               errormsg = mail_storage_get_last_error(storage, &error);
+               if (error == MAIL_ERROR_NOTPOSSIBLE) {
+                       storage->user->inbox_open_error_logged = TRUE;
+                       i_error("Syncing INBOX failed: %s", errormsg);
+               }
+       }
+       return ret;
 }
 
 int mailbox_sync(struct mailbox *box, enum mailbox_sync_flags flags)
index 2672e41609de5a088d7324bc964e568d8c092219..42d576997b63ef5487e3640605cb8a653d0f1c5d 100644 (file)
@@ -45,6 +45,8 @@ struct mail_user {
        unsigned int initialized:1;
        /* Shortcut to mail_storage_settings.mail_debug */
        unsigned int mail_debug:1;
+       /* If INBOX can't be opened, log an error, but only once. */
+       unsigned int inbox_open_error_logged:1;
 };
 
 struct mail_user_module_register {