]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
assert crashfixes
authorTimo Sirainen <tss@iki.fi>
Sun, 20 Jun 2004 13:02:08 +0000 (16:02 +0300)
committerTimo Sirainen <tss@iki.fi>
Sun, 20 Jun 2004 13:02:08 +0000 (16:02 +0300)
--HG--
branch : HEAD

src/lib-index/mail-index-sync-update.c
src/lib-index/mail-transaction-log.c

index 84792bc02a1c40b33c7d627f0c986c444e3c6c85..5c20955b3263b50c2d5171f3bef6f0e7e0f80a5d 100644 (file)
@@ -297,13 +297,17 @@ int mail_index_sync_update_index(struct mail_index_sync_ctx *sync_ctx)
        struct mail_index_map *map;
        const struct mail_transaction_header *hdr;
        const void *data;
-       unsigned int count;
+       unsigned int count, old_lock_id;
        uint32_t seq, i;
        uoff_t offset;
        int ret, had_dirty, skipped;
 
+       /* we'll have to update view->lock_id to avoid mail_index_view_lock()
+          trying to update the file later. */
+       old_lock_id = view->lock_id;
        if (mail_index_lock_exclusive(index, &view->lock_id) < 0)
                return -1;
+       mail_index_unlock(index, old_lock_id);
 
        /* NOTE: locking may change index->map so make sure assignment
           after locking */
@@ -343,8 +347,10 @@ int mail_index_sync_update_index(struct mail_index_sync_ctx *sync_ctx)
 
                if ((hdr->type & MAIL_TRANSACTION_APPEND) != 0) {
                        count = hdr->size / index->record_size;
-                       if (mail_index_grow(index, view->map, count) < 0)
-                               return -1;
+                       if (mail_index_grow(index, view->map, count) < 0) {
+                               ret = -1;
+                               break;
+                       }
                }
 
                if (mail_transaction_map(index, hdr, data,
@@ -355,8 +361,11 @@ int mail_index_sync_update_index(struct mail_index_sync_ctx *sync_ctx)
                }
        }
 
-       if (ret < 0)
+       if (ret < 0) {
+               /*  */
+               mail_index_view_unlock(view);
                return -1;
+       }
 
        i_assert(map->records_count == map->hdr->messages_count);
        i_assert(view->messages_count == map->hdr->messages_count);
index 2e4f0fb582d4400455cac7adaa685741b6b1960f..bcf4f7e1c984e91aeb69492f5865f61bc1a05ef8 100644 (file)
@@ -201,6 +201,9 @@ mail_transaction_log_file_lock(struct mail_transaction_log_file *file,
 {
        int ret;
 
+       if (lock_type == file->lock_type)
+               return 0;
+
        if (lock_type == F_UNLCK) {
                i_assert(file->lock_type != F_UNLCK);
        } else {