From: Timo Sirainen Date: Sun, 20 Jun 2004 13:02:08 +0000 (+0300) Subject: assert crashfixes X-Git-Tag: 1.1.alpha1~3896 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fec0e90484c5f2c9da9cdc62c0897408023d4c6e;p=thirdparty%2Fdovecot%2Fcore.git assert crashfixes --HG-- branch : HEAD --- diff --git a/src/lib-index/mail-index-sync-update.c b/src/lib-index/mail-index-sync-update.c index 84792bc02a..5c20955b32 100644 --- a/src/lib-index/mail-index-sync-update.c +++ b/src/lib-index/mail-index-sync-update.c @@ -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); diff --git a/src/lib-index/mail-transaction-log.c b/src/lib-index/mail-transaction-log.c index 2e4f0fb582..bcf4f7e1c9 100644 --- a/src/lib-index/mail-transaction-log.c +++ b/src/lib-index/mail-transaction-log.c @@ -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 {