]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Don't try to re-map dirty memory mapping.
authorTimo Sirainen <tss@iki.fi>
Sun, 23 May 2004 16:29:35 +0000 (19:29 +0300)
committerTimo Sirainen <tss@iki.fi>
Sun, 23 May 2004 16:29:35 +0000 (19:29 +0300)
--HG--
branch : HEAD

src/lib-index/mail-index.c

index f9b6fb504e6b88b3af4186772aa8d91d0654ca35..7c7c6ed7223aa7e8a4e3da8fe89063ae442d92b2 100644 (file)
@@ -134,6 +134,8 @@ 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);
+
        map->mmap_base = index->lock_type != F_WRLCK ?
                mmap_ro_file(index->fd, &map->mmap_size) :
                mmap_rw_file(index->fd, &map->mmap_size);
@@ -185,6 +187,8 @@ static int mail_index_read_map(struct mail_index *index,
        ssize_t ret;
        size_t pos, records_size;
 
+       i_assert(map->mmap_base == NULL);
+
        memset(&hdr, 0, sizeof(hdr));
 
        ret = 1;
@@ -272,6 +276,12 @@ int mail_index_map(struct mail_index *index, int force)
 
        map = index->map;
        if (map != NULL && MAIL_INDEX_MAP_IS_IN_MEMORY(map)) {
+               if (map->write_to_disk) {
+                       /* we have modified this mapping and it's waiting to
+                          be written to disk once we drop exclusive lock.
+                          mapping couldn't have changed, so do nothing. */
+                       return 1;
+               }
                /* FIXME: we need to re-read header */
        } else if (map != NULL) {
                /* see if re-mmaping is needed (file has grown) */