[dovecot-cvs] dovecot/src/lib-index mail-index-data.c,1.42,1.43
cras at procontrol.fi
cras at procontrol.fi
Thu May 15 23:42:14 EEST 2003
Update of /home/cvs/dovecot/src/lib-index
In directory danu:/tmp/cvs-serv6245/lib-index
Modified Files:
mail-index-data.c
Log Message:
Reset the header using mmaped memory + msync, instead of lseek() + write()
which was buggy with OpenBSD (didn't update the mmap).
Index: mail-index-data.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index-data.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- mail-index-data.c 27 Apr 2003 00:59:43 -0000 1.42
+++ mail-index-data.c 15 May 2003 19:42:12 -0000 1.43
@@ -358,20 +358,16 @@
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;
More information about the dovecot-cvs
mailing list