[dovecot-cvs] dovecot/src/lib-index
mail-index-transaction-private.h, 1.24,
1.25 mail-index-transaction.c, 1.59, 1.60 mail-index.h, 1.148,
1.149 mail-transaction-log-append.c, 1.9, 1.10
cras at dovecot.org
cras at dovecot.org
Sat Apr 23 18:18:24 EEST 2005
Update of /var/lib/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv28538/lib-index
Modified Files:
mail-index-transaction-private.h mail-index-transaction.c
mail-index.h mail-transaction-log-append.c
Log Message:
If UIDVALIDITY changes, don't invalidate the whole index. Just expunge all
existing messages and update uidvalidity/nextuid fields. Now we don't have
to re-login when this happens.
Index: mail-index-transaction-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-transaction-private.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- mail-index-transaction-private.h 2 Apr 2005 21:09:03 -0000 1.24
+++ mail-index-transaction-private.h 23 Apr 2005 15:18:21 -0000 1.25
@@ -19,8 +19,10 @@
array_t ARRAY_DEFINE(updates, struct mail_transaction_flag_update);
size_t last_update_idx;
- unsigned char hdr_change[sizeof(struct mail_index_header)];
- unsigned char hdr_mask[sizeof(struct mail_index_header)];
+ unsigned char pre_hdr_change[sizeof(struct mail_index_header)];
+ unsigned char pre_hdr_mask[sizeof(struct mail_index_header)];
+ unsigned char post_hdr_change[sizeof(struct mail_index_header)];
+ unsigned char post_hdr_mask[sizeof(struct mail_index_header)];
array_t ARRAY_DEFINE(ext_rec_updates, array_t);
array_t ARRAY_DEFINE(ext_resizes, struct mail_transaction_ext_intro);
@@ -35,7 +37,8 @@
unsigned int hide_transaction:1;
unsigned int no_appends:1;
unsigned int external:1;
- unsigned int hdr_changed:1;
+ unsigned int pre_hdr_changed:1;
+ unsigned int post_hdr_changed:1;
unsigned int log_updates:1;
};
Index: mail-index-transaction.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-transaction.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- mail-index-transaction.c 7 Apr 2005 23:02:47 -0000 1.59
+++ mail-index-transaction.c 23 Apr 2005 15:18:21 -0000 1.60
@@ -705,17 +705,25 @@
}
void mail_index_update_header(struct mail_index_transaction *t,
- size_t offset, const void *data, size_t size)
+ size_t offset, const void *data, size_t size,
+ int prepend)
{
- i_assert(offset < sizeof(t->hdr_change));
- i_assert(size <= sizeof(t->hdr_change) - offset);
+ i_assert(offset < sizeof(t->pre_hdr_change));
+ i_assert(size <= sizeof(t->pre_hdr_change) - offset);
- t->hdr_changed = TRUE;
t->log_updates = TRUE;
- memcpy(t->hdr_change + offset, data, size);
- for (; size > 0; size--)
- t->hdr_mask[offset++] = 1;
+ if (prepend) {
+ t->pre_hdr_changed = TRUE;
+ memcpy(t->pre_hdr_change + offset, data, size);
+ for (; size > 0; size--)
+ t->pre_hdr_mask[offset++] = 1;
+ } else {
+ t->post_hdr_changed = TRUE;
+ memcpy(t->post_hdr_change + offset, data, size);
+ for (; size > 0; size--)
+ t->post_hdr_mask[offset++] = 1;
+ }
}
void mail_index_ext_resize(struct mail_index_transaction *t, uint32_t ext_id,
Index: mail-index.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index.h,v
retrieving revision 1.148
retrieving revision 1.149
diff -u -d -r1.148 -r1.149
--- mail-index.h 8 Apr 2005 12:14:42 -0000 1.148
+++ mail-index.h 23 Apr 2005 15:18:21 -0000 1.149
@@ -326,9 +326,11 @@
enum modify_type modify_type,
struct mail_keywords *keywords);
-/* Update field in header. */
+/* Update field in header. If prepend is TRUE, the header change is visible
+ before message syncing begins. */
void mail_index_update_header(struct mail_index_transaction *t,
- size_t offset, const void *data, size_t size);
+ size_t offset, const void *data, size_t size,
+ int prepend);
/* Returns the last error code. */
enum mail_index_error mail_index_get_last_error(struct mail_index *index);
Index: mail-transaction-log-append.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-transaction-log-append.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- mail-transaction-log-append.c 16 Apr 2005 22:01:11 -0000 1.9
+++ mail-transaction-log-append.c 23 Apr 2005 15:18:21 -0000 1.10
@@ -80,18 +80,22 @@
}
static const buffer_t *
-log_get_hdr_update_buffer(struct mail_index_transaction *t)
+log_get_hdr_update_buffer(struct mail_index_transaction *t, int prepend)
{
buffer_t *buf;
+ const unsigned char *data, *mask;
struct mail_transaction_header_update u;
uint16_t offset;
int state = 0;
memset(&u, 0, sizeof(u));
+ data = prepend ? t->pre_hdr_change : t->post_hdr_change;
+ mask = prepend ? t->pre_hdr_mask : t->post_hdr_mask;
+
buf = buffer_create_dynamic(pool_datastack_create(), 256);
- for (offset = 0; offset <= sizeof(t->hdr_change); offset++) {
- if (offset < sizeof(t->hdr_change) && t->hdr_mask[offset]) {
+ for (offset = 0; offset <= sizeof(t->pre_hdr_change); offset++) {
+ if (offset < sizeof(t->pre_hdr_change) && mask[offset]) {
if (state == 0) {
u.offset = offset;
state++;
@@ -99,9 +103,8 @@
} else {
if (state > 0) {
u.size = offset - u.offset;
- buffer_append(buf, &u, sizeof(uint16_t)*2);
- buffer_append(buf, t->hdr_change + u.offset,
- u.size);
+ buffer_append(buf, &u, sizeof(u));
+ buffer_append(buf, data + u.offset, u.size);
state = 0;
}
}
@@ -411,6 +414,12 @@
to avoid resize overhead as much as possible */
ret = mail_transaction_log_append_ext_intros(file, t);
+ if (t->pre_hdr_changed && ret == 0) {
+ ret = log_append_buffer(file,
+ log_get_hdr_update_buffer(t, TRUE),
+ NULL, MAIL_TRANSACTION_HEADER_UPDATE,
+ t->external);
+ }
if (array_is_created(&t->appends) && ret == 0) {
visibility_changes = TRUE;
ret = log_append_buffer(file, t->appends.buffer, NULL,
@@ -442,16 +451,17 @@
ret = log_append_buffer(file, t->expunges.buffer, NULL,
MAIL_TRANSACTION_EXPUNGE, t->external);
}
- if (t->hdr_changed && ret == 0) {
- ret = log_append_buffer(file, log_get_hdr_update_buffer(t),
- NULL, MAIL_TRANSACTION_HEADER_UPDATE,
- t->external);
- }
if (ret < 0) {
mail_index_file_set_syscall_error(log->index, file->filepath,
"pwrite()");
}
+ if (t->post_hdr_changed && ret == 0) {
+ ret = log_append_buffer(file,
+ log_get_hdr_update_buffer(t, FALSE),
+ NULL, MAIL_TRANSACTION_HEADER_UPDATE,
+ t->external);
+ }
if (ret == 0 && visibility_changes && t->hide_transaction) {
mail_index_view_add_synced_transaction(view, file->hdr.file_seq,
More information about the dovecot-cvs
mailing list