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

src/lib-index/mail-index.c

index 584327129ed18ab8ad4c25a2a03b9b2b8bf7256b..0225aa59d0e438695eeccc9fc00d28dbef585af3 100644 (file)
@@ -199,7 +199,13 @@ static int mail_index_mmap(struct mail_index *index, struct mail_index_map *map)
        const struct mail_index_header *hdr;
        unsigned int records_count;
 
-       i_assert(map->buffer == NULL);
+       i_assert(!map->write_to_disk);
+
+       if (map->buffer != NULL) {
+               /* we had temporarily used a buffer, eg. for updating index */
+               buffer_free(map->buffer);
+               map->buffer = NULL;
+       }
 
        map->mmap_base = index->lock_type != F_WRLCK ?
                mmap_ro_file(index->fd, &map->mmap_size) :
@@ -352,6 +358,7 @@ int mail_index_map(struct mail_index *index, int force)
                /* FIXME: we need to re-read header */
        } else if (map->mmap_base != NULL) {
                /* see if re-mmaping is needed (file has grown) */
+               i_assert(map->buffer == NULL);
                hdr = map->mmap_base;
 
                /* always check corrupted-flag to avoid errors later */