]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Reset the header using mmaped memory + msync, instead of lseek() + write()
authorTimo Sirainen <tss@iki.fi>
Thu, 15 May 2003 19:42:12 +0000 (22:42 +0300)
committerTimo Sirainen <tss@iki.fi>
Thu, 15 May 2003 19:42:12 +0000 (22:42 +0300)
which was buggy with OpenBSD (didn't update the mmap).

--HG--
branch : HEAD

src/lib-index/mail-index-data.c

index b25bb39abd0d84ec42fc6ec49faf03843b854840..cb9a127439fd34f8f788f350440fc86419efcc2b 100644 (file)
@@ -358,21 +358,17 @@ int mail_index_data_reset(struct mail_index_data *data)
        memset(&hdr, 0, sizeof(struct mail_index_data_header));
        hdr.indexid = data->index->indexid;
        hdr.used_file_size = sizeof(struct mail_index_data_header);
+       memcpy(data->mmap_base, &hdr, sizeof(hdr));
 
-       if (data->anon_mmap) {
-               memcpy(data->mmap_base, &hdr, sizeof(hdr));
+       if (data->anon_mmap)
                return TRUE;
-       }
+
+       if (msync(data->mmap_base, sizeof(hdr), MS_SYNC) < 0)
+               return index_data_set_syscall_error(data, "msync()");
 
        if (file_set_size(data->fd, INDEX_DATA_INITIAL_SIZE) < 0)
                return index_data_set_syscall_error(data, "file_set_size()");
 
-       if (lseek(data->fd, 0, SEEK_SET) < 0)
-               return index_data_set_syscall_error(data, "lseek()");
-
-       if (write_full(data->fd, &hdr, sizeof(hdr)) < 0)
-               return index_data_set_syscall_error(data, "write_full()");
-
        data->modified = FALSE;
        data->fsynced = FALSE;
        return mmap_update(data, 0, 0);