# HG changeset patch # User Timo Sirainen # Date 1167339299 -7200 # Node ID a9babc1b3c65faa3b0d49df5943e8477a30cd31f # Parent 4d947423c82fa35900fc6fb0c68a04d279d36e32 If there are transactions left while unlocking, don't unlock. Also added some next_uid debugging. diff -r 4d947423c82f -r a9babc1b3c65 src/lib-index/mail-index-sync-update.c --- a/src/lib-index/mail-index-sync-update.c Thu Dec 28 22:52:32 2006 +0200 +++ b/src/lib-index/mail-index-sync-update.c Thu Dec 28 22:54:59 2006 +0200 @@ -291,6 +291,7 @@ map->hdr.next_uid = rec->uid+1; map->records_count++; view->hdr.messages_count++; + view->hdr.next_uid = rec->uid+1; write_seq_update(map, map->hdr.messages_count, map->hdr.messages_count); diff -r 4d947423c82f -r a9babc1b3c65 src/lib-index/mail-index-view.c --- a/src/lib-index/mail-index-view.c Thu Dec 28 22:52:32 2006 +0200 +++ b/src/lib-index/mail-index-view.c Thu Dec 28 22:54:59 2006 +0200 @@ -53,10 +53,26 @@ i_free(view); } +#ifdef DEBUG +static void mail_index_view_check_nextuid(struct mail_index_view *view) +{ + struct mail_index_record *rec; + + if (view->hdr.messages_count == 0) + return; + + rec = MAIL_INDEX_MAP_IDX(view->map, view->hdr.messages_count-1); + i_assert(rec->uid < view->hdr.next_uid); +} +#endif + int mail_index_view_lock_head(struct mail_index_view *view, bool update_index) { unsigned int lock_id; +#ifdef DEBUG + mail_index_view_check_nextuid(view); +#endif if (MAIL_INDEX_MAP_IS_IN_MEMORY(view->index->map)) return 0; @@ -95,6 +111,9 @@ if (view->map != view->index->map) { /* not head mapping, no need to lock */ +#ifdef DEBUG + mail_index_view_check_nextuid(view); +#endif return 0; } @@ -103,7 +122,11 @@ void mail_index_view_unlock(struct mail_index_view *view) { - if (view->lock_id != 0) { +#ifdef DEBUG + mail_index_view_check_nextuid(view); +#endif + + if (view->lock_id != 0 && view->transactions == 0) { mail_index_unlock(view->index, view->lock_id); view->lock_id = 0; } @@ -461,6 +484,9 @@ if (--view->refcount > 0) return; + i_assert(view->transactions == 0); + + mail_index_view_unlock(view); view->v.close(view); }