[dovecot-cvs] dovecot/src/lib-index mail-index-sync-update.c, 1.27,
1.28 mail-index-view.c, 1.15, 1.16 mail-index.c, 1.135, 1.136
cras at procontrol.fi
cras at procontrol.fi
Sun Jun 20 15:23:29 EEST 2004
Update of /home/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv11519/lib-index
Modified Files:
mail-index-sync-update.c mail-index-view.c mail-index.c
Log Message:
Index syncing fixes.
Index: mail-index-sync-update.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index-sync-update.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- mail-index-sync-update.c 20 Jun 2004 09:13:14 -0000 1.27
+++ mail-index-sync-update.c 20 Jun 2004 12:23:27 -0000 1.28
@@ -250,6 +250,7 @@
static int mail_index_grow(struct mail_index *index, struct mail_index_map *map,
unsigned int count)
{
+ struct mail_index_header hdr;
size_t size;
if (MAIL_INDEX_MAP_IS_IN_MEMORY(map))
@@ -274,9 +275,17 @@
if (file_set_size(index->fd, (off_t)size) < 0)
return mail_index_set_syscall_error(index, "file_set_size()");
+ /* we only wish to grow the file, but mail_index_map() updates the
+ headers as well and may break our modified hdr_copy. so, take
+ a backup of it and put it back afterwards */
+ hdr = map->hdr_copy;
+
if (mail_index_map(index, TRUE) <= 0)
return -1;
+ map->hdr_copy = hdr;
+ map->hdr = &map->hdr_copy;
+
i_assert(map->mmap_size >= size);
return 0;
}
@@ -288,12 +297,12 @@
struct mail_index_map *map;
const struct mail_transaction_header *hdr;
const void *data;
- unsigned int lock_id, count;
+ unsigned int count;
uint32_t seq, i;
uoff_t offset;
int ret, had_dirty, skipped;
- if (mail_index_lock_exclusive(index, &lock_id) < 0)
+ if (mail_index_lock_exclusive(index, &view->lock_id) < 0)
return -1;
/* NOTE: locking may change index->map so make sure assignment
@@ -349,6 +358,9 @@
if (ret < 0)
return -1;
+ i_assert(map->records_count == map->hdr->messages_count);
+ i_assert(view->messages_count == map->hdr->messages_count);
+
mail_transaction_log_get_head(index->log, &seq, &offset);
map->hdr_copy.log_file_seq = seq;
@@ -381,7 +393,7 @@
map->hdr = map->mmap_base;
}
- mail_index_unlock(index, lock_id);
+ mail_index_view_unlock(view);
return ret;
}
Index: mail-index-view.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index-view.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- mail-index-view.c 20 Jun 2004 09:13:14 -0000 1.15
+++ mail-index-view.c 20 Jun 2004 12:23:27 -0000 1.16
@@ -51,6 +51,9 @@
{
unsigned int lock_id;
+ if (MAIL_INDEX_MAP_IS_IN_MEMORY(view->index->map))
+ return 0;
+
if (!mail_index_is_locked(view->index, view->lock_id)) {
if (mail_index_lock_shared(view->index, update_index,
&view->lock_id) < 0)
Index: mail-index.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index.c,v
retrieving revision 1.135
retrieving revision 1.136
diff -u -d -r1.135 -r1.136
--- mail-index.c 20 Jun 2004 08:05:41 -0000 1.135
+++ mail-index.c 20 Jun 2004 12:23:27 -0000 1.136
@@ -412,7 +412,6 @@
struct mail_index_map *
mail_index_map_to_memory(struct mail_index *index, struct mail_index_map *map)
{
- const struct mail_index_header *hdr;
struct mail_index_map *mem_map;
size_t size;
@@ -431,9 +430,7 @@
mem_map->records = buffer_get_modifyable_data(mem_map->buffer, NULL);
mem_map->records_count = map->records_count;
- hdr = map->mmap_base;
- memcpy(&mem_map->hdr_copy, map->mmap_base,
- I_MIN(hdr->base_header_size, sizeof(mem_map->hdr_copy)));
+ mem_map->hdr_copy = *map->hdr;
mem_map->hdr = &mem_map->hdr_copy;
return mem_map;
}
More information about the dovecot-cvs
mailing list