[dovecot-cvs] dovecot/src/lib-index mail-cache-lookup.c, 1.22,
1.23 mail-cache-private.h, 1.15, 1.16 mail-cache.c, 1.46, 1.47
cras at dovecot.org
cras at dovecot.org
Thu Sep 16 17:33:18 EEST 2004
Update of /var/lib/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv25727/lib-index
Modified Files:
mail-cache-lookup.c mail-cache-private.h mail-cache.c
Log Message:
Fix for circular record list detection, we can't use data stack for buffer.
Index: mail-cache-lookup.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-cache-lookup.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- mail-cache-lookup.c 16 Sep 2004 14:03:00 -0000 1.22
+++ mail-cache-lookup.c 16 Sep 2004 14:33:16 -0000 1.23
@@ -162,7 +162,6 @@
mail_cache_foreach_callback_t *callback, void *context)
{
uint32_t offset;
- buffer_t *offsets;
int ret;
if (MAIL_CACHE_IS_UNUSABLE(view->cache))
@@ -178,38 +177,34 @@
view->cached_offset = offset;
}
- t_push();
- offsets = buffer_create_dynamic(pool_datastack_create(),
- 128, (size_t)-1);
ret = 1;
+ buffer_set_used_size(view->offsets_buf, 0);
while (offset != 0 && ret > 0) {
- if (buffer_find_offset(offsets, offset)) {
+ if (buffer_find_offset(view->offsets_buf, offset)) {
mail_cache_set_corrupted(view->cache,
"record list is circular");
- ret = -1;
- break;
+ return -1;
}
- buffer_append(offsets, &offset, sizeof(offset));
+ buffer_append(view->offsets_buf, &offset, sizeof(offset));
ret = mail_cache_foreach_rec(view, &offset,
callback, context);
}
if (ret > 0 && view->trans_seq1 <= seq && view->trans_seq2 >= seq &&
mail_cache_transaction_lookup(view->transaction, seq, &offset)) {
- buffer_set_used_size(offsets, 0);
+ buffer_set_used_size(view->offsets_buf, 0);
while (offset != 0 && ret > 0) {
- if (buffer_find_offset(offsets, offset)) {
+ if (buffer_find_offset(view->offsets_buf, offset)) {
mail_cache_set_corrupted(view->cache,
"record list is circular");
- ret = -1;
- break;
+ return -1;
}
- buffer_append(offsets, &offset, sizeof(offset));
+ buffer_append(view->offsets_buf,
+ &offset, sizeof(offset));
ret = mail_cache_foreach_rec(view, &offset,
callback, context);
}
}
- t_pop();
return ret;
}
Index: mail-cache-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-cache-private.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- mail-cache-private.h 12 Sep 2004 14:02:46 -0000 1.15
+++ mail-cache-private.h 16 Sep 2004 14:33:16 -0000 1.16
@@ -147,6 +147,8 @@
struct mail_cache_transaction_ctx *transaction;
uint32_t trans_seq1, trans_seq2;
+ buffer_t *offsets_buf; /* temporary buffer, just to avoid mallocs */
+
/* if cached_exists_buf[field] == cached_exists_value, it's cached.
this allows us to avoid constantly clearing the whole buffer.
it needs to be cleared only when cached_exists_value is wrapped. */
Index: mail-cache.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-cache.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- mail-cache.c 31 Jul 2004 03:06:48 -0000 1.46
+++ mail-cache.c 16 Sep 2004 14:33:16 -0000 1.47
@@ -333,6 +333,8 @@
view = i_new(struct mail_cache_view, 1);
view->cache = cache;
view->view = iview;
+ view->offsets_buf =
+ buffer_create_dynamic(default_pool, 128, (size_t)-1);
view->cached_exists_buf =
buffer_create_dynamic(default_pool,
cache->file_fields_count + 10,
@@ -345,6 +347,7 @@
if (view->cache->field_header_write_pending)
(void)mail_cache_header_fields_update(view->cache);
+ buffer_free(view->offsets_buf);
buffer_free(view->cached_exists_buf);
i_free(view);
}
More information about the dovecot-cvs
mailing list