]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
sdbox: Avoid logging multiple adjacent "Invalid dbox header size" errors.
authorTimo Sirainen <tss@iki.fi>
Sun, 4 Apr 2010 20:01:23 +0000 (23:01 +0300)
committerTimo Sirainen <tss@iki.fi>
Sun, 4 Apr 2010 20:01:23 +0000 (23:01 +0300)
--HG--
branch : HEAD

src/lib-storage/index/dbox-single/sdbox-storage.c
src/lib-storage/index/dbox-single/sdbox-storage.h
src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c
src/lib-storage/index/dbox-single/sdbox-sync.c

index d0cfeb196444ef8cc483fe1352155d82a162f6d4..f315e63180780d263d0f43bc766425649428d74a 100644 (file)
@@ -64,7 +64,7 @@ sdbox_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
 }
 
 int sdbox_read_header(struct sdbox_mailbox *mbox,
-                     struct sdbox_index_header *hdr)
+                     struct sdbox_index_header *hdr, bool log_error)
 {
        const void *data;
        size_t data_size;
@@ -73,9 +73,12 @@ int sdbox_read_header(struct sdbox_mailbox *mbox,
                                  &data, &data_size);
        if (data_size < SDBOX_INDEX_HEADER_MIN_SIZE &&
            (!mbox->creating || data_size != 0)) {
-               mail_storage_set_critical(&mbox->storage->storage.storage,
-                       "dbox %s: Invalid dbox header size",
-                       mbox->box.path);
+               if (log_error) {
+                       mail_storage_set_critical(
+                               &mbox->storage->storage.storage,
+                               "dbox %s: Invalid dbox header size",
+                               mbox->box.path);
+               }
                return -1;
        }
        memset(hdr, 0, sizeof(*hdr));
@@ -89,7 +92,7 @@ void sdbox_update_header(struct sdbox_mailbox *mbox,
 {
        struct sdbox_index_header hdr, new_hdr;
 
-       if (sdbox_read_header(mbox, &hdr) < 0)
+       if (sdbox_read_header(mbox, &hdr, TRUE) < 0)
                memset(&hdr, 0, sizeof(hdr));
 
        new_hdr = hdr;
@@ -176,13 +179,13 @@ sdbox_mailbox_get_guid(struct mailbox *box, uint8_t guid[MAIL_GUID_128_SIZE])
        struct sdbox_mailbox *mbox = (struct sdbox_mailbox *)box;
        struct sdbox_index_header hdr;
 
-       if (sdbox_read_header(mbox, &hdr) < 0)
+       if (sdbox_read_header(mbox, &hdr, TRUE) < 0)
                memset(&hdr, 0, sizeof(hdr));
 
        if (mail_guid_128_is_empty(hdr.mailbox_guid)) {
                /* regenerate it */
                if (sdbox_write_index_header(box, NULL) < 0 ||
-                   sdbox_read_header(mbox, &hdr) < 0)
+                   sdbox_read_header(mbox, &hdr, TRUE) < 0)
                        return -1;
        }
        memcpy(guid, hdr.mailbox_guid, MAIL_GUID_128_SIZE);
index 1728a317514d41239c756b0edf714742cb292b4f..df1052d5d8ddfff403b723af87e068ade4d6a2b2 100644 (file)
@@ -40,7 +40,7 @@ int sdbox_mail_open(struct dbox_mail *mail, uoff_t *offset_r,
 
 uint32_t dbox_get_uidvalidity_next(struct mailbox_list *list);
 int sdbox_read_header(struct sdbox_mailbox *mbox,
-                     struct sdbox_index_header *hdr);
+                     struct sdbox_index_header *hdr, bool log_error);
 void sdbox_update_header(struct sdbox_mailbox *mbox,
                         struct mail_index_transaction *trans,
                         const struct mailbox_update *update);
index 3014fca957a5cb4574f38aa20ee08c6364df31f9..416df214416ec5debca98dd24ed04107c75c3c74 100644 (file)
@@ -130,7 +130,7 @@ static void sdbox_sync_update_header(struct dbox_sync_rebuild_context *ctx)
        struct sdbox_mailbox *mbox = (struct sdbox_mailbox *)ctx->box;
        struct sdbox_index_header hdr;
 
-       if (sdbox_read_header(mbox, &hdr) < 0)
+       if (sdbox_read_header(mbox, &hdr, FALSE) < 0)
                memset(&hdr, 0, sizeof(hdr));
        if (!mail_guid_128_is_empty(hdr.mailbox_guid))
                mail_generate_guid_128(hdr.mailbox_guid);
index 3886debd7ce18f77cfd368bd1a46f431873c0c8e..1e698517bb6cd003dcdab72432d1ff71e9ff4fe9 100644 (file)
@@ -142,21 +142,22 @@ static int sdbox_sync_index(struct sdbox_sync_context *ctx)
        return ret;
 }
 
-static int sdbox_refresh_header(struct sdbox_mailbox *mbox, bool retry)
+static int
+sdbox_refresh_header(struct sdbox_mailbox *mbox, bool retry, bool log_error)
 {
        struct mail_index_view *view;
        struct sdbox_index_header hdr;
        int ret;
 
        view = mail_index_view_open(mbox->box.index);
-       ret = sdbox_read_header(mbox, &hdr);
+       ret = sdbox_read_header(mbox, &hdr, log_error);
        mail_index_view_close(&view);
 
        if (ret == 0) {
                ret = mbox->sync_rebuild ? -1 : 0;
        } else if (retry) {
                (void)mail_index_refresh(mbox->box.index);
-               return sdbox_refresh_header(mbox, FALSE);
+               return sdbox_refresh_header(mbox, FALSE, log_error);
        }
        return ret;
 }
@@ -171,7 +172,7 @@ int sdbox_sync_begin(struct sdbox_mailbox *mbox, enum sdbox_sync_flags flags,
        int ret;
        bool rebuild;
 
-       rebuild = sdbox_refresh_header(mbox, TRUE) < 0 ||
+       rebuild = sdbox_refresh_header(mbox, TRUE, FALSE) < 0 ||
                (flags & SDBOX_SYNC_FLAG_FORCE_REBUILD) != 0;
 
        ctx = i_new(struct sdbox_sync_context, 1);
@@ -199,8 +200,8 @@ int sdbox_sync_begin(struct sdbox_mailbox *mbox, enum sdbox_sync_flags flags,
                        return ret;
                }
 
-               /* now that we're locked, check again if we want to rebuild */
-               if (sdbox_refresh_header(mbox, FALSE) < 0)
+               /* now that we're locked, check again if we want to rebuild. */
+               if (sdbox_refresh_header(mbox, FALSE, TRUE) < 0)
                        ret = 0;
                else {
                        if ((ret = sdbox_sync_index(ctx)) > 0)