[dovecot-cvs] dovecot/src/lib-index mail-tree.c,1.18,1.19 mail-index.c,1.87,1.88 mail-index-data.c,1.40,1.41
cras at procontrol.fi
cras at procontrol.fi
Wed Apr 23 21:07:25 EEST 2003
Update of /home/cvs/dovecot/src/lib-index
In directory danu:/tmp/cvs-serv29316
Modified Files:
mail-tree.c mail-index.c mail-index-data.c
Log Message:
Don't call msync() with with in-memory indexes.
Index: mail-tree.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-tree.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- mail-tree.c 23 Apr 2003 13:23:14 -0000 1.18
+++ mail-tree.c 23 Apr 2003 17:07:23 -0000 1.19
@@ -55,7 +55,7 @@
if (tree->mmap_base != NULL) {
/* make sure we're synced before munmap() */
- if (tree->modified &&
+ if (!tree->anon_mmap && tree->modified &&
msync(tree->mmap_base, tree->mmap_highwater, MS_SYNC) < 0)
return tree_set_syscall_error(tree, "msync()");
tree->modified = FALSE;
Index: mail-index.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index.c,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -d -r1.87 -r1.88
--- mail-index.c 15 Apr 2003 23:13:49 -0000 1.87
+++ mail-index.c 23 Apr 2003 17:07:23 -0000 1.88
@@ -261,7 +261,7 @@
static int mail_index_write_header_changes(struct mail_index *index)
{
- int failed;
+ int failed = FALSE;
/* use our own locking here so we don't mess up with any other
index states, like inconsistency. */
@@ -275,10 +275,13 @@
mail_index_update_header_changes(index);
- failed = msync(index->mmap_base,
- sizeof(struct mail_index_header), MS_SYNC) < 0;
- if (failed)
- index_set_syscall_error(index, "msync()");
+ if (!index->anon_mmap) {
+ if (msync(index->mmap_base,
+ sizeof(struct mail_index_header), MS_SYNC) < 0) {
+ index_set_syscall_error(index, "msync()");
+ failed = TRUE;
+ }
+ }
#ifdef DEBUG
mprotect(index->mmap_base, index->mmap_used_length, PROT_NONE);
@@ -446,7 +449,8 @@
/* remove the FSCK flag only after successful fsync() */
if (mail_index_sync_file(index) && !keep_fsck) {
index->header->flags &= ~MAIL_INDEX_FLAG_FSCK;
- if (msync(index->mmap_base,
+ if (!index->anon_mmap &&
+ msync(index->mmap_base,
sizeof(struct mail_index_header),
MS_SYNC) < 0) {
/* we only failed to remove the fsck flag,
Index: mail-index-data.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index-data.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- mail-index-data.c 23 Apr 2003 13:23:14 -0000 1.40
+++ mail-index-data.c 23 Apr 2003 17:07:23 -0000 1.41
@@ -76,14 +76,25 @@
return FALSE;
}
-static void mail_index_data_file_close(struct mail_index_data *data)
+static int mail_index_data_msync(struct mail_index_data *data)
{
- if (data->modified) {
+ if (!data->modified)
+ return TRUE;
+
+ if (!data->anon_mmap) {
if (msync(data->mmap_base, data->mmap_used_length, MS_SYNC) < 0)
- index_data_set_syscall_error(data, "msync()");
- data->modified = FALSE;
+ return index_data_set_syscall_error(data, "msync()");
}
+ data->modified = FALSE;
+ data->fsynced = FALSE;
+ return TRUE;
+}
+
+static void mail_index_data_file_close(struct mail_index_data *data)
+{
+ (void)mail_index_data_msync(data);
+
if (data->anon_mmap) {
if (munmap_anon(data->mmap_base, data->mmap_full_length) < 0)
index_data_set_syscall_error(data, "munmap_anon()");
@@ -164,11 +175,8 @@
i_assert(!data->anon_mmap);
if (data->mmap_base != NULL) {
- if (data->modified &&
- msync(data->mmap_base, data->mmap_used_length, MS_SYNC) < 0)
- return index_data_set_syscall_error(data, "msync()");
- data->modified = FALSE;
- data->fsynced = FALSE;
+ if (!mail_index_data_msync(data))
+ return FALSE;
if (munmap(data->mmap_base, data->mmap_full_length) < 0)
index_data_set_syscall_error(data, "munmap()");
@@ -504,12 +512,8 @@
if (data->anon_mmap)
return TRUE;
- if (data->modified) {
- if (msync(data->mmap_base, data->mmap_used_length, MS_SYNC) < 0)
- return index_data_set_syscall_error(data, "msync()");
-
- data->fsynced = FALSE;
- }
+ if (!mail_index_data_msync(data))
+ return FALSE;
if (!data->fsynced) {
data->fsynced = TRUE;
More information about the dovecot-cvs
mailing list