[dovecot-cvs] dovecot/src/lib-index mail-cache-compress.c, 1.16,
1.17 mail-cache-lookup.c, 1.20, 1.21 mail-cache-private.h,
1.14, 1.15
cras at dovecot.org
cras at dovecot.org
Sun Sep 12 17:02:49 EEST 2004
Update of /var/lib/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv4526/lib-index
Modified Files:
mail-cache-compress.c mail-cache-lookup.c mail-cache-private.h
Log Message:
ID mapping fixes.
Index: mail-cache-compress.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-cache-compress.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- mail-cache-compress.c 11 Sep 2004 17:25:39 -0000 1.16
+++ mail-cache-compress.c 12 Sep 2004 14:02:46 -0000 1.17
@@ -13,11 +13,11 @@
};
static void mail_cache_merge_bitmask(struct mail_cache *cache, buffer_t *buffer,
- uint32_t file_field, const void *data,
+ uint32_t field, const void *data,
size_t data_size)
{
void *buf_data;
- uint32_t field, buf_file_field;
+ uint32_t buf_file_field;
unsigned int i, buf_data_size;
size_t pos, buf_size;
@@ -26,7 +26,6 @@
buf_file_field = *((uint32_t *)PTR_OFFSET(buf_data, pos));
pos += sizeof(uint32_t);
- field = cache->file_field_map[file_field];
buf_data_size = cache->fields[field].field.field_size;
if (buf_data_size == (unsigned int)-1) {
buf_data_size =
@@ -34,7 +33,7 @@
pos += sizeof(uint32_t);
}
- if (buf_file_field == file_field) {
+ if (cache->file_field_map[buf_file_field] == field) {
/* found it, do the merging */
unsigned char *dest = PTR_OFFSET(buf_data, pos);
@@ -48,20 +47,18 @@
}
static int
-mail_cache_compress_callback(struct mail_cache_view *view, uint32_t file_field,
+mail_cache_compress_callback(struct mail_cache_view *view, uint32_t field,
const void *data, size_t data_size, void *context)
{
struct mail_cache_copy_context *ctx = context;
struct mail_cache_field *cache_field;
enum mail_cache_decision_type dec;
- unsigned int field;
uint8_t *field_seen;
uint32_t size32;
- field = view->cache->file_field_map[file_field];
cache_field = &view->cache->fields[field].field;
- field_seen = buffer_get_space_unsafe(ctx->field_seen, file_field, 1);
+ field_seen = buffer_get_space_unsafe(ctx->field_seen, field, 1);
if (*field_seen == ctx->field_seen_value) {
/* duplicate */
if (cache_field->type == MAIL_CACHE_FIELD_BITMASK) {
@@ -81,7 +78,7 @@
return 1;
}
- buffer_append(ctx->buffer, &file_field, sizeof(file_field));
+ buffer_append(ctx->buffer, &field, sizeof(field));
if (cache_field->field_size == (unsigned int)-1) {
size32 = (uint32_t)data_size;
@@ -105,7 +102,7 @@
struct mail_cache_record cache_rec;
struct ostream *output;
buffer_t *buffer;
- uint32_t message_count, seq, first_new_seq, old_offset;
+ uint32_t i, message_count, seq, first_new_seq, old_offset;
uoff_t offset;
/* get sequence of first message which doesn't need it's temp fields
@@ -134,19 +131,6 @@
hdr.file_seq = idx_hdr->cache_file_seq + 1;
o_stream_send(output, &hdr, sizeof(hdr));
- if (cache->fields_count != 0) {
- hdr.field_header_offset =
- mail_index_uint32_to_offset(output->offset);
-
- t_push();
- buffer = buffer_create_dynamic(pool_datastack_create(),
- 256, (size_t)-1);
- mail_cache_header_fields_get(cache, buffer);
- o_stream_send(output, buffer_get_data(buffer, NULL),
- buffer_get_used_size(buffer));
- t_pop();
- }
-
memset(&ctx, 0, sizeof(ctx));
ctx.buffer = buffer_create_dynamic(default_pool, 4096, (size_t)-1);
ctx.field_seen = buffer_create_dynamic(default_pool, 64, (size_t)-1);
@@ -181,6 +165,27 @@
o_stream_send(output, buffer_get_data(ctx.buffer, NULL),
cache_rec.size);
}
+
+ if (cache->fields_count != 0) {
+ hdr.field_header_offset =
+ mail_index_uint32_to_offset(output->offset);
+
+ /* we wrote everything using our internal data_ids. so we want
+ mail_cache_header_fields_get() to use them and ignore any
+ existing id mappings in the old cache file. */
+ cache->file_fields_count = 0;
+ for (i = 0; i < cache->fields_count; i++)
+ cache->field_file_map[i] = (uint32_t)-1;
+
+ t_push();
+ buffer = buffer_create_dynamic(pool_datastack_create(),
+ 256, (size_t)-1);
+ mail_cache_header_fields_get(cache, buffer);
+ o_stream_send(output, buffer_get_data(buffer, NULL),
+ buffer_get_used_size(buffer));
+ t_pop();
+ }
+
hdr.used_file_size = output->offset;
buffer_free(ctx.buffer);
Index: mail-cache-lookup.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-cache-lookup.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- mail-cache-lookup.c 11 Sep 2004 19:21:08 -0000 1.20
+++ mail-cache-lookup.c 12 Sep 2004 14:02:46 -0000 1.21
@@ -130,8 +130,7 @@
return -1;
}
- ret = callback(view, file_field,
- CONST_PTR_OFFSET(cache_rec, pos),
+ ret = callback(view, field, CONST_PTR_OFFSET(cache_rec, pos),
data_size, context);
if (ret != 1)
return ret;
@@ -182,12 +181,12 @@
}
static int
-mail_cache_seq_callback(struct mail_cache_view *view, uint32_t file_field,
+mail_cache_seq_callback(struct mail_cache_view *view, uint32_t field,
const void *data __attr_unused__,
size_t data_size __attr_unused__,
void *context __attr_unused__)
{
- buffer_write(view->cached_exists_buf, file_field,
+ buffer_write(view->cached_exists_buf, field,
&view->cached_exists_value, 1);
return 1;
}
@@ -229,8 +228,8 @@
}
data = buffer_get_data(view->cached_exists_buf, &size);
- return size <= file_field ? FALSE :
- data[file_field] == view->cached_exists_value;
+ return size <= field ? FALSE :
+ data[field] == view->cached_exists_value;
}
enum mail_cache_decision_type
@@ -243,18 +242,18 @@
struct mail_cache_lookup_context {
buffer_t *dest_buf;
- uint32_t file_field;
+ uint32_t field;
int found;
};
static int
mail_cache_lookup_callback(struct mail_cache_view *view __attr_unused__,
- uint32_t file_field, const void *data,
+ uint32_t field, const void *data,
size_t data_size, void *context)
{
struct mail_cache_lookup_context *ctx = context;
- if (ctx->file_field != file_field)
+ if (ctx->field != field)
return 1;
buffer_append(ctx->dest_buf, data, data_size);
@@ -264,14 +263,14 @@
static int
mail_cache_lookup_bitmask_callback(struct mail_cache_view *view __attr_unused__,
- uint32_t file_field, const void *data,
+ uint32_t field, const void *data,
size_t data_size, void *context)
{
struct mail_cache_lookup_context *ctx = context;
unsigned char *dest;
size_t i;
- if (ctx->file_field != file_field)
+ if (ctx->field != field)
return 1;
/* merge all bits */
@@ -295,7 +294,7 @@
mail_cache_decision_lookup(view, seq, field);
/* should exist. find it. */
- ctx.file_field = view->cache->field_file_map[field];
+ ctx.field = field;
ctx.dest_buf = dest_buf;
ctx.found = FALSE;
if (view->cache->fields[field].field.type != MAIL_CACHE_FIELD_BITMASK) {
@@ -334,7 +333,7 @@
};
static int
-headers_find_callback(struct mail_cache_view *view, uint32_t file_field,
+headers_find_callback(struct mail_cache_view *view, uint32_t field,
const void *data, size_t data_size, void *context)
{
struct header_lookup_context *ctx = context;
@@ -343,11 +342,11 @@
struct header_lookup_data_rec *hdr_data_rec;
unsigned int i, lines_count;
- if (file_field > ctx->max_field || ctx->fields_found[file_field] != 1) {
+ if (field > ctx->max_field || ctx->fields_found[field] != 1) {
/* a) don't want it, b) duplicate */
return 1;
}
- ctx->fields_found[file_field]++;
+ ctx->fields_found[field]++;
/* data = { line_nums[], 0, "headers" } */
for (i = 0; data_size >= sizeof(uint32_t); i++) {
@@ -387,7 +386,6 @@
struct header_lookup_data *data;
const unsigned char *p, *start, *end;
size_t i, size, hdr_size;
- unsigned int field_idx;
uint8_t one = 1;
buffer_t *buf;
int ret;
@@ -406,18 +404,17 @@
buf = buffer_create_dynamic(pool_datastack_create(), 32, (size_t)-1);
for (i = 0; i < fields_count; i++) {
i_assert(fields[i] < cache->fields_count);
- field_idx = cache->field_file_map[fields[i]];
- if (field_idx == (unsigned int)-1) {
+ if (cache->field_file_map[fields[i]] == (unsigned int)-1) {
/* not cached at all */
t_pop();
return 0;
}
- if (field_idx > ctx.max_field)
- ctx.max_field = field_idx;
+ if (fields[i] > ctx.max_field)
+ ctx.max_field = fields[i];
- buffer_write(buf, field_idx, &one, 1);
- ctx.fields[i] = field_idx;
+ buffer_write(buf, fields[i], &one, 1);
+ ctx.fields[i] = fields[i];
}
ctx.fields_found = buffer_get_modifyable_data(buf, NULL);
Index: mail-cache-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-cache-private.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- mail-cache-private.h 31 Jul 2004 03:06:48 -0000 1.14
+++ mail-cache-private.h 12 Sep 2004 14:02:46 -0000 1.15
@@ -157,7 +157,7 @@
};
typedef int mail_cache_foreach_callback_t(struct mail_cache_view *view,
- uint32_t file_field,
+ uint32_t field,
const void *data, size_t data_size,
void *context);
More information about the dovecot-cvs
mailing list