annotate src/lib-index/mail-transaction-log-view.c @ 4842:57c5e40e26dd HEAD

Compile fix
author Timo Sirainen <tss@iki.fi>
date Sun, 19 Nov 2006 16:35:55 +0200
parents 7cc1b8fec8ab
children 987397c331d7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
1 /* Copyright (C) 2003-2004 Timo Sirainen */
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
2
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
3 #include "lib.h"
4828
7cc1b8fec8ab Reference counting fixes. Fixes an assert crash when closing the index.
Timo Sirainen <tss@iki.fi>
parents: 4785
diff changeset
4 #include "array.h"
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
5 #include "mail-index-private.h"
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
6 #include "mail-transaction-log-private.h"
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
7 #include "mail-transaction-util.h"
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
8
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
9 struct mail_transaction_log_view {
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
10 struct mail_transaction_log *log;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
11 struct mail_transaction_log_view *next;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
12
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
13 uint32_t min_file_seq, max_file_seq;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
14 uoff_t min_file_offset, max_file_offset;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
15
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
16 enum mail_transaction_type type_mask;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
17 struct mail_transaction_header tmp_hdr;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
18
4828
7cc1b8fec8ab Reference counting fixes. Fixes an assert crash when closing the index.
Timo Sirainen <tss@iki.fi>
parents: 4785
diff changeset
19 /* a list of log files we've referenced. we have to keep this list
7cc1b8fec8ab Reference counting fixes. Fixes an assert crash when closing the index.
Timo Sirainen <tss@iki.fi>
parents: 4785
diff changeset
20 explicitly because more files may be added into the linked list
7cc1b8fec8ab Reference counting fixes. Fixes an assert crash when closing the index.
Timo Sirainen <tss@iki.fi>
parents: 4785
diff changeset
21 at any time. */
4842
57c5e40e26dd Compile fix
Timo Sirainen <tss@iki.fi>
parents: 4828
diff changeset
22 ARRAY_DEFINE(file_refs, struct mail_transaction_log_file *);
2074
cb5269c052e0 Keep the transaction log view open all the time for index views (not just
Timo Sirainen <tss@iki.fi>
parents: 2050
diff changeset
23 struct mail_transaction_log_file *cur, *head, *tail;
cb5269c052e0 Keep the transaction log view open all the time for index views (not just
Timo Sirainen <tss@iki.fi>
parents: 2050
diff changeset
24 uoff_t cur_offset;
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
25
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
26 uint32_t prev_file_seq;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
27 uoff_t prev_file_offset;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
28
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
29 unsigned int broken:1;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
30 };
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
31
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
32 struct mail_transaction_log_view *
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
33 mail_transaction_log_view_open(struct mail_transaction_log *log)
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
34 {
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
35 struct mail_transaction_log_view *view;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
36
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
37 view = i_new(struct mail_transaction_log_view, 1);
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
38 view->log = log;
1941
ced8e41c137a automatically fix broken/missing transaction log files on the fly
Timo Sirainen <tss@iki.fi>
parents: 1940
diff changeset
39 view->broken = TRUE;
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
40
2074
cb5269c052e0 Keep the transaction log view open all the time for index views (not just
Timo Sirainen <tss@iki.fi>
parents: 2050
diff changeset
41 view->head = view->tail = view->log->head;
cb5269c052e0 Keep the transaction log view open all the time for index views (not just
Timo Sirainen <tss@iki.fi>
parents: 2050
diff changeset
42 view->head->refcount++;
4842
57c5e40e26dd Compile fix
Timo Sirainen <tss@iki.fi>
parents: 4828
diff changeset
43 i_array_init(&view->file_refs, 8);
4828
7cc1b8fec8ab Reference counting fixes. Fixes an assert crash when closing the index.
Timo Sirainen <tss@iki.fi>
parents: 4785
diff changeset
44 array_append(&view->file_refs, &view->head, 1);
2074
cb5269c052e0 Keep the transaction log view open all the time for index views (not just
Timo Sirainen <tss@iki.fi>
parents: 2050
diff changeset
45
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
46 view->next = log->views;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
47 log->views = view;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
48 return view;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
49 }
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
50
4828
7cc1b8fec8ab Reference counting fixes. Fixes an assert crash when closing the index.
Timo Sirainen <tss@iki.fi>
parents: 4785
diff changeset
51 static void
7cc1b8fec8ab Reference counting fixes. Fixes an assert crash when closing the index.
Timo Sirainen <tss@iki.fi>
parents: 4785
diff changeset
52 mail_transaction_log_view_unref_all(struct mail_transaction_log_view *view)
7cc1b8fec8ab Reference counting fixes. Fixes an assert crash when closing the index.
Timo Sirainen <tss@iki.fi>
parents: 4785
diff changeset
53 {
7cc1b8fec8ab Reference counting fixes. Fixes an assert crash when closing the index.
Timo Sirainen <tss@iki.fi>
parents: 4785
diff changeset
54 struct mail_transaction_log_file *const *files;
7cc1b8fec8ab Reference counting fixes. Fixes an assert crash when closing the index.
Timo Sirainen <tss@iki.fi>
parents: 4785
diff changeset
55 unsigned int i, count;
7cc1b8fec8ab Reference counting fixes. Fixes an assert crash when closing the index.
Timo Sirainen <tss@iki.fi>
parents: 4785
diff changeset
56
7cc1b8fec8ab Reference counting fixes. Fixes an assert crash when closing the index.
Timo Sirainen <tss@iki.fi>
parents: 4785
diff changeset
57 files = array_get(&view->file_refs, &count);
7cc1b8fec8ab Reference counting fixes. Fixes an assert crash when closing the index.
Timo Sirainen <tss@iki.fi>
parents: 4785
diff changeset
58 for (i = 0; i < count; i++)
7cc1b8fec8ab Reference counting fixes. Fixes an assert crash when closing the index.
Timo Sirainen <tss@iki.fi>
parents: 4785
diff changeset
59 files[i]->refcount--;
7cc1b8fec8ab Reference counting fixes. Fixes an assert crash when closing the index.
Timo Sirainen <tss@iki.fi>
parents: 4785
diff changeset
60
7cc1b8fec8ab Reference counting fixes. Fixes an assert crash when closing the index.
Timo Sirainen <tss@iki.fi>
parents: 4785
diff changeset
61 array_clear(&view->file_refs);
7cc1b8fec8ab Reference counting fixes. Fixes an assert crash when closing the index.
Timo Sirainen <tss@iki.fi>
parents: 4785
diff changeset
62 }
7cc1b8fec8ab Reference counting fixes. Fixes an assert crash when closing the index.
Timo Sirainen <tss@iki.fi>
parents: 4785
diff changeset
63
3879
928229f8b3e6 deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
64 void mail_transaction_log_view_close(struct mail_transaction_log_view **_view)
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
65 {
3879
928229f8b3e6 deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
66 struct mail_transaction_log_view *view = *_view;
1942
2b114aa7eeec handle losing index file
Timo Sirainen <tss@iki.fi>
parents: 1941
diff changeset
67 struct mail_transaction_log_view **p;
2b114aa7eeec handle losing index file
Timo Sirainen <tss@iki.fi>
parents: 1941
diff changeset
68
3879
928229f8b3e6 deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
69 *_view = NULL;
928229f8b3e6 deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
70
1942
2b114aa7eeec handle losing index file
Timo Sirainen <tss@iki.fi>
parents: 1941
diff changeset
71 for (p = &view->log->views; *p != NULL; p = &(*p)->next) {
2b114aa7eeec handle losing index file
Timo Sirainen <tss@iki.fi>
parents: 1941
diff changeset
72 if (*p == view) {
2b114aa7eeec handle losing index file
Timo Sirainen <tss@iki.fi>
parents: 1941
diff changeset
73 *p = view->next;
2b114aa7eeec handle losing index file
Timo Sirainen <tss@iki.fi>
parents: 1941
diff changeset
74 break;
2b114aa7eeec handle losing index file
Timo Sirainen <tss@iki.fi>
parents: 1941
diff changeset
75 }
2b114aa7eeec handle losing index file
Timo Sirainen <tss@iki.fi>
parents: 1941
diff changeset
76 }
2b114aa7eeec handle losing index file
Timo Sirainen <tss@iki.fi>
parents: 1941
diff changeset
77
4828
7cc1b8fec8ab Reference counting fixes. Fixes an assert crash when closing the index.
Timo Sirainen <tss@iki.fi>
parents: 4785
diff changeset
78 mail_transaction_log_view_unref_all(view);
7cc1b8fec8ab Reference counting fixes. Fixes an assert crash when closing the index.
Timo Sirainen <tss@iki.fi>
parents: 4785
diff changeset
79 mail_transaction_logs_clean(view->log);
2074
cb5269c052e0 Keep the transaction log view open all the time for index views (not just
Timo Sirainen <tss@iki.fi>
parents: 2050
diff changeset
80
4828
7cc1b8fec8ab Reference counting fixes. Fixes an assert crash when closing the index.
Timo Sirainen <tss@iki.fi>
parents: 4785
diff changeset
81 array_free(&view->file_refs);
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
82 i_free(view);
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
83 }
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
84
1942
2b114aa7eeec handle losing index file
Timo Sirainen <tss@iki.fi>
parents: 1941
diff changeset
85 void mail_transaction_log_views_close(struct mail_transaction_log *log)
2b114aa7eeec handle losing index file
Timo Sirainen <tss@iki.fi>
parents: 1941
diff changeset
86 {
2b114aa7eeec handle losing index file
Timo Sirainen <tss@iki.fi>
parents: 1941
diff changeset
87 struct mail_transaction_log_view *view;
2b114aa7eeec handle losing index file
Timo Sirainen <tss@iki.fi>
parents: 1941
diff changeset
88
2b114aa7eeec handle losing index file
Timo Sirainen <tss@iki.fi>
parents: 1941
diff changeset
89 for (view = log->views; view != NULL; view = view->next)
2b114aa7eeec handle losing index file
Timo Sirainen <tss@iki.fi>
parents: 1941
diff changeset
90 view->log = NULL;
2b114aa7eeec handle losing index file
Timo Sirainen <tss@iki.fi>
parents: 1941
diff changeset
91 }
2b114aa7eeec handle losing index file
Timo Sirainen <tss@iki.fi>
parents: 1941
diff changeset
92
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
93 int
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
94 mail_transaction_log_view_set(struct mail_transaction_log_view *view,
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
95 uint32_t min_file_seq, uoff_t min_file_offset,
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
96 uint32_t max_file_seq, uoff_t max_file_offset,
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
97 enum mail_transaction_type type_mask)
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
98 {
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
99 struct mail_transaction_log_file *file, *first;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
100 uint32_t seq;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
101 uoff_t end_offset;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
102 int ret;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
103
3832
76f4be7ae499 Handle missing/broken transaction logs better. Handle broken sync position
Timo Sirainen <tss@iki.fi>
parents: 3649
diff changeset
104 i_assert(view->log != NULL);
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
105 i_assert(min_file_seq <= max_file_seq);
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
106
3832
76f4be7ae499 Handle missing/broken transaction logs better. Handle broken sync position
Timo Sirainen <tss@iki.fi>
parents: 3649
diff changeset
107 if (view->log == NULL) {
76f4be7ae499 Handle missing/broken transaction logs better. Handle broken sync position
Timo Sirainen <tss@iki.fi>
parents: 3649
diff changeset
108 /* transaction log is closed already. this log view shouldn't
76f4be7ae499 Handle missing/broken transaction logs better. Handle broken sync position
Timo Sirainen <tss@iki.fi>
parents: 3649
diff changeset
109 be used anymore. */
1942
2b114aa7eeec handle losing index file
Timo Sirainen <tss@iki.fi>
parents: 1941
diff changeset
110 return -1;
3832
76f4be7ae499 Handle missing/broken transaction logs better. Handle broken sync position
Timo Sirainen <tss@iki.fi>
parents: 3649
diff changeset
111 }
1942
2b114aa7eeec handle losing index file
Timo Sirainen <tss@iki.fi>
parents: 1941
diff changeset
112
2507
5ad6ccb8000b Handle correctly the case when index hasn't yet been synced with transaction
Timo Sirainen <tss@iki.fi>
parents: 2418
diff changeset
113 if (min_file_seq == 0) {
5ad6ccb8000b Handle correctly the case when index hasn't yet been synced with transaction
Timo Sirainen <tss@iki.fi>
parents: 2418
diff changeset
114 /* new index, transaction file not synced yet */
5ad6ccb8000b Handle correctly the case when index hasn't yet been synced with transaction
Timo Sirainen <tss@iki.fi>
parents: 2418
diff changeset
115 min_file_seq = 1;
3173
d137899ea853 We could have gone past the transaction log view's boundaries if log was
Timo Sirainen <tss@iki.fi>
parents: 2885
diff changeset
116 min_file_offset = 0;
2507
5ad6ccb8000b Handle correctly the case when index hasn't yet been synced with transaction
Timo Sirainen <tss@iki.fi>
parents: 2418
diff changeset
117
5ad6ccb8000b Handle correctly the case when index hasn't yet been synced with transaction
Timo Sirainen <tss@iki.fi>
parents: 2418
diff changeset
118 if (max_file_seq == 0) {
5ad6ccb8000b Handle correctly the case when index hasn't yet been synced with transaction
Timo Sirainen <tss@iki.fi>
parents: 2418
diff changeset
119 max_file_seq = min_file_seq;
5ad6ccb8000b Handle correctly the case when index hasn't yet been synced with transaction
Timo Sirainen <tss@iki.fi>
parents: 2418
diff changeset
120 max_file_offset = min_file_offset;
5ad6ccb8000b Handle correctly the case when index hasn't yet been synced with transaction
Timo Sirainen <tss@iki.fi>
parents: 2418
diff changeset
121 }
3173
d137899ea853 We could have gone past the transaction log view's boundaries if log was
Timo Sirainen <tss@iki.fi>
parents: 2885
diff changeset
122 }
2507
5ad6ccb8000b Handle correctly the case when index hasn't yet been synced with transaction
Timo Sirainen <tss@iki.fi>
parents: 2418
diff changeset
123
4785
a18fa2b4bf06 Code cleanup
Timo Sirainen <tss@iki.fi>
parents: 4784
diff changeset
124 if (min_file_seq == view->log->files->hdr.prev_file_seq &&
a18fa2b4bf06 Code cleanup
Timo Sirainen <tss@iki.fi>
parents: 4784
diff changeset
125 min_file_offset == view->log->files->hdr.prev_file_offset) {
2085
258c8ef1bdc4 assert fix
Timo Sirainen <tss@iki.fi>
parents: 2074
diff changeset
126 /* we can skip this */
4785
a18fa2b4bf06 Code cleanup
Timo Sirainen <tss@iki.fi>
parents: 4784
diff changeset
127 min_file_seq = view->log->files->hdr.file_seq;
3173
d137899ea853 We could have gone past the transaction log view's boundaries if log was
Timo Sirainen <tss@iki.fi>
parents: 2885
diff changeset
128 min_file_offset = 0;
1935
ec4d5ff99f6e Don't modify index file when creating new transaction log.
Timo Sirainen <tss@iki.fi>
parents: 1933
diff changeset
129
ec4d5ff99f6e Don't modify index file when creating new transaction log.
Timo Sirainen <tss@iki.fi>
parents: 1933
diff changeset
130 if (min_file_seq > max_file_seq) {
ec4d5ff99f6e Don't modify index file when creating new transaction log.
Timo Sirainen <tss@iki.fi>
parents: 1933
diff changeset
131 /* empty view */
ec4d5ff99f6e Don't modify index file when creating new transaction log.
Timo Sirainen <tss@iki.fi>
parents: 1933
diff changeset
132 max_file_seq = min_file_seq;
ec4d5ff99f6e Don't modify index file when creating new transaction log.
Timo Sirainen <tss@iki.fi>
parents: 1933
diff changeset
133 max_file_offset = min_file_offset;
ec4d5ff99f6e Don't modify index file when creating new transaction log.
Timo Sirainen <tss@iki.fi>
parents: 1933
diff changeset
134 }
ec4d5ff99f6e Don't modify index file when creating new transaction log.
Timo Sirainen <tss@iki.fi>
parents: 1933
diff changeset
135 }
1952
05f76fe32f0d Don't crash in assert() with corrupted index file.
Timo Sirainen <tss@iki.fi>
parents: 1942
diff changeset
136
3320
0403596c93fd index.log file is now rotated to .index.log.2 file. When log file is
Timo Sirainen <tss@iki.fi>
parents: 3304
diff changeset
137 /* find the oldest log file first. */
2085
258c8ef1bdc4 assert fix
Timo Sirainen <tss@iki.fi>
parents: 2074
diff changeset
138 ret = mail_transaction_log_file_find(view->log, min_file_seq, &file);
3832
76f4be7ae499 Handle missing/broken transaction logs better. Handle broken sync position
Timo Sirainen <tss@iki.fi>
parents: 3649
diff changeset
139 if (ret <= 0)
76f4be7ae499 Handle missing/broken transaction logs better. Handle broken sync position
Timo Sirainen <tss@iki.fi>
parents: 3649
diff changeset
140 return ret;
2085
258c8ef1bdc4 assert fix
Timo Sirainen <tss@iki.fi>
parents: 2074
diff changeset
141
3173
d137899ea853 We could have gone past the transaction log view's boundaries if log was
Timo Sirainen <tss@iki.fi>
parents: 2885
diff changeset
142 if (min_file_offset == 0) {
d137899ea853 We could have gone past the transaction log view's boundaries if log was
Timo Sirainen <tss@iki.fi>
parents: 2885
diff changeset
143 /* this could happen if internal transactions haven't yet been
d137899ea853 We could have gone past the transaction log view's boundaries if log was
Timo Sirainen <tss@iki.fi>
parents: 2885
diff changeset
144 committed but external are. just assume we're at the
d137899ea853 We could have gone past the transaction log view's boundaries if log was
Timo Sirainen <tss@iki.fi>
parents: 2885
diff changeset
145 beginning. */
d137899ea853 We could have gone past the transaction log view's boundaries if log was
Timo Sirainen <tss@iki.fi>
parents: 2885
diff changeset
146 min_file_offset = file->hdr.hdr_size;
d137899ea853 We could have gone past the transaction log view's boundaries if log was
Timo Sirainen <tss@iki.fi>
parents: 2885
diff changeset
147 if (max_file_offset == 0 && min_file_seq == max_file_seq)
d137899ea853 We could have gone past the transaction log view's boundaries if log was
Timo Sirainen <tss@iki.fi>
parents: 2885
diff changeset
148 max_file_offset = min_file_offset;
d137899ea853 We could have gone past the transaction log view's boundaries if log was
Timo Sirainen <tss@iki.fi>
parents: 2885
diff changeset
149 }
d137899ea853 We could have gone past the transaction log view's boundaries if log was
Timo Sirainen <tss@iki.fi>
parents: 2885
diff changeset
150
1952
05f76fe32f0d Don't crash in assert() with corrupted index file.
Timo Sirainen <tss@iki.fi>
parents: 1942
diff changeset
151 /* check these later than others as index file may have corrupted
05f76fe32f0d Don't crash in assert() with corrupted index file.
Timo Sirainen <tss@iki.fi>
parents: 1942
diff changeset
152 log_file_offset. we should have recreated the log file and
05f76fe32f0d Don't crash in assert() with corrupted index file.
Timo Sirainen <tss@iki.fi>
parents: 1942
diff changeset
153 skipped min_file_seq file above.. max_file_offset can be broken
05f76fe32f0d Don't crash in assert() with corrupted index file.
Timo Sirainen <tss@iki.fi>
parents: 1942
diff changeset
154 only if min_file_seq = max_file_seq. */
3173
d137899ea853 We could have gone past the transaction log view's boundaries if log was
Timo Sirainen <tss@iki.fi>
parents: 2885
diff changeset
155 i_assert(min_file_offset >= file->hdr.hdr_size);
2087
a11f8fa33848 added assert
Timo Sirainen <tss@iki.fi>
parents: 2085
diff changeset
156 i_assert(min_file_seq != max_file_seq ||
a11f8fa33848 added assert
Timo Sirainen <tss@iki.fi>
parents: 2085
diff changeset
157 min_file_offset <= max_file_offset);
a11f8fa33848 added assert
Timo Sirainen <tss@iki.fi>
parents: 2085
diff changeset
158
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
159 end_offset = min_file_seq == max_file_seq ?
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
160 max_file_offset : (uoff_t)-1;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
161 ret = mail_transaction_log_file_map(file, min_file_offset, end_offset);
3832
76f4be7ae499 Handle missing/broken transaction logs better. Handle broken sync position
Timo Sirainen <tss@iki.fi>
parents: 3649
diff changeset
162 if (ret <= 0)
76f4be7ae499 Handle missing/broken transaction logs better. Handle broken sync position
Timo Sirainen <tss@iki.fi>
parents: 3649
diff changeset
163 return ret;
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
164 first = file;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
165
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
166 for (seq = min_file_seq+1; seq <= max_file_seq; seq++) {
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
167 file = file->next;
3320
0403596c93fd index.log file is now rotated to .index.log.2 file. When log file is
Timo Sirainen <tss@iki.fi>
parents: 3304
diff changeset
168 if (file == NULL || file->hdr.file_seq != seq) {
0403596c93fd index.log file is now rotated to .index.log.2 file. When log file is
Timo Sirainen <tss@iki.fi>
parents: 3304
diff changeset
169 /* see if we could find the missing file */
0403596c93fd index.log file is now rotated to .index.log.2 file. When log file is
Timo Sirainen <tss@iki.fi>
parents: 3304
diff changeset
170 ret = mail_transaction_log_file_find(view->log,
0403596c93fd index.log file is now rotated to .index.log.2 file. When log file is
Timo Sirainen <tss@iki.fi>
parents: 3304
diff changeset
171 seq, &file);
0403596c93fd index.log file is now rotated to .index.log.2 file. When log file is
Timo Sirainen <tss@iki.fi>
parents: 3304
diff changeset
172 if (ret <= 0) {
0403596c93fd index.log file is now rotated to .index.log.2 file. When log file is
Timo Sirainen <tss@iki.fi>
parents: 3304
diff changeset
173 if (ret < 0)
0403596c93fd index.log file is now rotated to .index.log.2 file. When log file is
Timo Sirainen <tss@iki.fi>
parents: 3304
diff changeset
174 return -1;
0403596c93fd index.log file is now rotated to .index.log.2 file. When log file is
Timo Sirainen <tss@iki.fi>
parents: 3304
diff changeset
175
0403596c93fd index.log file is now rotated to .index.log.2 file. When log file is
Timo Sirainen <tss@iki.fi>
parents: 3304
diff changeset
176 /* not found / corrupted */
0403596c93fd index.log file is now rotated to .index.log.2 file. When log file is
Timo Sirainen <tss@iki.fi>
parents: 3304
diff changeset
177 file = NULL;
0403596c93fd index.log file is now rotated to .index.log.2 file. When log file is
Timo Sirainen <tss@iki.fi>
parents: 3304
diff changeset
178 }
0403596c93fd index.log file is now rotated to .index.log.2 file. When log file is
Timo Sirainen <tss@iki.fi>
parents: 3304
diff changeset
179 }
0403596c93fd index.log file is now rotated to .index.log.2 file. When log file is
Timo Sirainen <tss@iki.fi>
parents: 3304
diff changeset
180
0403596c93fd index.log file is now rotated to .index.log.2 file. When log file is
Timo Sirainen <tss@iki.fi>
parents: 3304
diff changeset
181 if (file == NULL || file->hdr.file_seq != seq) {
2885
1880f191278a Avoid re-reading index file with mmap_disabled=yes. Instead sync it by
Timo Sirainen <tss@iki.fi>
parents: 2882
diff changeset
182 if (file == NULL && max_file_seq == (uint32_t)-1) {
1880f191278a Avoid re-reading index file with mmap_disabled=yes. Instead sync it by
Timo Sirainen <tss@iki.fi>
parents: 2882
diff changeset
183 /* we just wanted to sync everything */
1880f191278a Avoid re-reading index file with mmap_disabled=yes. Instead sync it by
Timo Sirainen <tss@iki.fi>
parents: 2882
diff changeset
184 max_file_seq = seq-1;
1880f191278a Avoid re-reading index file with mmap_disabled=yes. Instead sync it by
Timo Sirainen <tss@iki.fi>
parents: 2882
diff changeset
185 break;
1880f191278a Avoid re-reading index file with mmap_disabled=yes. Instead sync it by
Timo Sirainen <tss@iki.fi>
parents: 2882
diff changeset
186 }
1880f191278a Avoid re-reading index file with mmap_disabled=yes. Instead sync it by
Timo Sirainen <tss@iki.fi>
parents: 2882
diff changeset
187
3320
0403596c93fd index.log file is now rotated to .index.log.2 file. When log file is
Timo Sirainen <tss@iki.fi>
parents: 3304
diff changeset
188 /* missing files in the middle */
3832
76f4be7ae499 Handle missing/broken transaction logs better. Handle broken sync position
Timo Sirainen <tss@iki.fi>
parents: 3649
diff changeset
189 return 0;
2091
2450b4ff4894 show error messages when log files are missing
Timo Sirainen <tss@iki.fi>
parents: 2087
diff changeset
190 }
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
191
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
192 end_offset = file->hdr.file_seq == max_file_seq ?
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
193 max_file_offset : (uoff_t)-1;
3173
d137899ea853 We could have gone past the transaction log view's boundaries if log was
Timo Sirainen <tss@iki.fi>
parents: 2885
diff changeset
194 ret = mail_transaction_log_file_map(file, file->hdr.hdr_size,
d137899ea853 We could have gone past the transaction log view's boundaries if log was
Timo Sirainen <tss@iki.fi>
parents: 2885
diff changeset
195 end_offset);
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
196 if (ret <= 0)
3832
76f4be7ae499 Handle missing/broken transaction logs better. Handle broken sync position
Timo Sirainen <tss@iki.fi>
parents: 3649
diff changeset
197 return ret;
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
198 }
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
199
2418
f32a2fd0c8b4 assert crashfix
Timo Sirainen <tss@iki.fi>
parents: 2410
diff changeset
200 i_assert(max_file_offset == (uoff_t)-1 ||
f32a2fd0c8b4 assert crashfix
Timo Sirainen <tss@iki.fi>
parents: 2410
diff changeset
201 max_file_offset <= file->sync_offset);
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
202
2074
cb5269c052e0 Keep the transaction log view open all the time for index views (not just
Timo Sirainen <tss@iki.fi>
parents: 2050
diff changeset
203 /* we have all of them. update refcounts. */
4828
7cc1b8fec8ab Reference counting fixes. Fixes an assert crash when closing the index.
Timo Sirainen <tss@iki.fi>
parents: 4785
diff changeset
204 mail_transaction_log_view_unref_all(view);
7cc1b8fec8ab Reference counting fixes. Fixes an assert crash when closing the index.
Timo Sirainen <tss@iki.fi>
parents: 4785
diff changeset
205
7cc1b8fec8ab Reference counting fixes. Fixes an assert crash when closing the index.
Timo Sirainen <tss@iki.fi>
parents: 4785
diff changeset
206 view->tail = first;
7cc1b8fec8ab Reference counting fixes. Fixes an assert crash when closing the index.
Timo Sirainen <tss@iki.fi>
parents: 4785
diff changeset
207 view->head = view->log->head;
7cc1b8fec8ab Reference counting fixes. Fixes an assert crash when closing the index.
Timo Sirainen <tss@iki.fi>
parents: 4785
diff changeset
208
7cc1b8fec8ab Reference counting fixes. Fixes an assert crash when closing the index.
Timo Sirainen <tss@iki.fi>
parents: 4785
diff changeset
209 /* reference all used files */
7cc1b8fec8ab Reference counting fixes. Fixes an assert crash when closing the index.
Timo Sirainen <tss@iki.fi>
parents: 4785
diff changeset
210 for (file = view->tail; file != NULL; file = file->next) {
7cc1b8fec8ab Reference counting fixes. Fixes an assert crash when closing the index.
Timo Sirainen <tss@iki.fi>
parents: 4785
diff changeset
211 array_append(&view->file_refs, &file, 1);
7cc1b8fec8ab Reference counting fixes. Fixes an assert crash when closing the index.
Timo Sirainen <tss@iki.fi>
parents: 4785
diff changeset
212 file->refcount++;
2074
cb5269c052e0 Keep the transaction log view open all the time for index views (not just
Timo Sirainen <tss@iki.fi>
parents: 2050
diff changeset
213 }
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
214
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
215 view->prev_file_seq = 0;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
216 view->prev_file_offset = 0;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
217
2074
cb5269c052e0 Keep the transaction log view open all the time for index views (not just
Timo Sirainen <tss@iki.fi>
parents: 2050
diff changeset
218 view->cur = first;
cb5269c052e0 Keep the transaction log view open all the time for index views (not just
Timo Sirainen <tss@iki.fi>
parents: 2050
diff changeset
219 view->cur_offset = min_file_offset;
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
220
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
221 view->min_file_seq = min_file_seq;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
222 view->min_file_offset = min_file_offset;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
223 view->max_file_seq = max_file_seq;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
224 view->max_file_offset = max_file_offset;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
225 view->type_mask = type_mask;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
226 view->broken = FALSE;
3173
d137899ea853 We could have gone past the transaction log view's boundaries if log was
Timo Sirainen <tss@iki.fi>
parents: 2885
diff changeset
227
3180
ef16bb8091aa Several transaction log cleanups and fixes.
Timo Sirainen <tss@iki.fi>
parents: 3173
diff changeset
228 i_assert(view->cur_offset <= view->cur->sync_offset);
3173
d137899ea853 We could have gone past the transaction log view's boundaries if log was
Timo Sirainen <tss@iki.fi>
parents: 2885
diff changeset
229 i_assert(view->cur->hdr.file_seq == min_file_seq);
3832
76f4be7ae499 Handle missing/broken transaction logs better. Handle broken sync position
Timo Sirainen <tss@iki.fi>
parents: 3649
diff changeset
230 return 1;
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
231 }
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
232
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
233 void
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
234 mail_transaction_log_view_get_prev_pos(struct mail_transaction_log_view *view,
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
235 uint32_t *file_seq_r,
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
236 uoff_t *file_offset_r)
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
237 {
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
238 *file_seq_r = view->prev_file_seq;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
239 *file_offset_r = view->prev_file_offset;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
240 }
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
241
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
242 void
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
243 mail_transaction_log_view_set_corrupted(struct mail_transaction_log_view *view,
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
244 const char *fmt, ...)
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
245 {
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
246 va_list va;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
247
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
248 view->broken = TRUE;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
249
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
250 va_start(va, fmt);
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
251 t_push();
1919
4aeb7357951a locking fixes, mmap_disable=yes fixes
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
252 mail_transaction_log_file_set_corrupted(view->log->head, "%s",
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
253 t_strdup_vprintf(fmt, va));
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
254 t_pop();
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
255 va_end(va);
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
256 }
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
257
3863
55df57c028d4 Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents: 3832
diff changeset
258 bool
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
259 mail_transaction_log_view_is_corrupted(struct mail_transaction_log_view *view)
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
260 {
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
261 return view->broken;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
262 }
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
263
2616
13930bda8b69 Don't check extra updates data_id validity if we're just skipping over them.
Timo Sirainen <tss@iki.fi>
parents: 2585
diff changeset
264 static int
13930bda8b69 Don't check extra updates data_id validity if we're just skipping over them.
Timo Sirainen <tss@iki.fi>
parents: 2585
diff changeset
265 log_view_get_next(struct mail_transaction_log_view *view,
13930bda8b69 Don't check extra updates data_id validity if we're just skipping over them.
Timo Sirainen <tss@iki.fi>
parents: 2585
diff changeset
266 const struct mail_transaction_header **hdr_r,
2702
d6f25d0e104a Don't complain about corruption when there is none.
Timo Sirainen <tss@iki.fi>
parents: 2701
diff changeset
267 const void **data_r)
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
268 {
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
269 const struct mail_transaction_header *hdr;
1940
Timo Sirainen <tss@iki.fi>
parents: 1935
diff changeset
270 struct mail_transaction_log_file *file;
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
271 const struct mail_transaction_type_map *type_rec;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
272 const void *data;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
273 unsigned int record_size;
2407
fed6d07bd8ee Transaction log file is now read-lockless.
Timo Sirainen <tss@iki.fi>
parents: 2392
diff changeset
274 uint32_t hdr_size;
1933
bfdff8c75965 fixes for mmap_disable
Timo Sirainen <tss@iki.fi>
parents: 1922
diff changeset
275 size_t file_size;
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
276
3173
d137899ea853 We could have gone past the transaction log view's boundaries if log was
Timo Sirainen <tss@iki.fi>
parents: 2885
diff changeset
277 if (view->cur == NULL)
d137899ea853 We could have gone past the transaction log view's boundaries if log was
Timo Sirainen <tss@iki.fi>
parents: 2885
diff changeset
278 return 0;
d137899ea853 We could have gone past the transaction log view's boundaries if log was
Timo Sirainen <tss@iki.fi>
parents: 2885
diff changeset
279
3180
ef16bb8091aa Several transaction log cleanups and fixes.
Timo Sirainen <tss@iki.fi>
parents: 3173
diff changeset
280 /* prev_file_offset should point to beginning of previous log record.
ef16bb8091aa Several transaction log cleanups and fixes.
Timo Sirainen <tss@iki.fi>
parents: 3173
diff changeset
281 when we reach EOF, it should be left there, not to beginning of the
ef16bb8091aa Several transaction log cleanups and fixes.
Timo Sirainen <tss@iki.fi>
parents: 3173
diff changeset
282 next file. */
3173
d137899ea853 We could have gone past the transaction log view's boundaries if log was
Timo Sirainen <tss@iki.fi>
parents: 2885
diff changeset
283 view->prev_file_seq = view->cur->hdr.file_seq;
d137899ea853 We could have gone past the transaction log view's boundaries if log was
Timo Sirainen <tss@iki.fi>
parents: 2885
diff changeset
284 view->prev_file_offset = view->cur_offset;
d137899ea853 We could have gone past the transaction log view's boundaries if log was
Timo Sirainen <tss@iki.fi>
parents: 2885
diff changeset
285
3180
ef16bb8091aa Several transaction log cleanups and fixes.
Timo Sirainen <tss@iki.fi>
parents: 3173
diff changeset
286 if (view->cur->hdr.file_seq == view->max_file_seq) {
ef16bb8091aa Several transaction log cleanups and fixes.
Timo Sirainen <tss@iki.fi>
parents: 3173
diff changeset
287 /* last file */
ef16bb8091aa Several transaction log cleanups and fixes.
Timo Sirainen <tss@iki.fi>
parents: 3173
diff changeset
288 if (view->cur_offset == view->max_file_offset ||
ef16bb8091aa Several transaction log cleanups and fixes.
Timo Sirainen <tss@iki.fi>
parents: 3173
diff changeset
289 view->cur_offset == view->cur->sync_offset) {
ef16bb8091aa Several transaction log cleanups and fixes.
Timo Sirainen <tss@iki.fi>
parents: 3173
diff changeset
290 /* we're all finished */
ef16bb8091aa Several transaction log cleanups and fixes.
Timo Sirainen <tss@iki.fi>
parents: 3173
diff changeset
291 view->cur = NULL;
ef16bb8091aa Several transaction log cleanups and fixes.
Timo Sirainen <tss@iki.fi>
parents: 3173
diff changeset
292 return 0;
ef16bb8091aa Several transaction log cleanups and fixes.
Timo Sirainen <tss@iki.fi>
parents: 3173
diff changeset
293 }
ef16bb8091aa Several transaction log cleanups and fixes.
Timo Sirainen <tss@iki.fi>
parents: 3173
diff changeset
294 } else if (view->cur_offset == view->cur->sync_offset) {
ef16bb8091aa Several transaction log cleanups and fixes.
Timo Sirainen <tss@iki.fi>
parents: 3173
diff changeset
295 /* end of file, go to next one */
ef16bb8091aa Several transaction log cleanups and fixes.
Timo Sirainen <tss@iki.fi>
parents: 3173
diff changeset
296 view->cur = view->cur->next;
ef16bb8091aa Several transaction log cleanups and fixes.
Timo Sirainen <tss@iki.fi>
parents: 3173
diff changeset
297 if (view->cur == NULL)
2331
e5748645a9d6 Don't crash if mail_index_view_sync_next() is called again after it's finished.
Timo Sirainen <tss@iki.fi>
parents: 2115
diff changeset
298 return 0;
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
299
3180
ef16bb8091aa Several transaction log cleanups and fixes.
Timo Sirainen <tss@iki.fi>
parents: 3173
diff changeset
300 view->cur_offset = view->cur->hdr.hdr_size;
ef16bb8091aa Several transaction log cleanups and fixes.
Timo Sirainen <tss@iki.fi>
parents: 3173
diff changeset
301 return log_view_get_next(view, hdr_r, data_r);
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
302 }
3180
ef16bb8091aa Several transaction log cleanups and fixes.
Timo Sirainen <tss@iki.fi>
parents: 3173
diff changeset
303 file = view->cur;
2392
dad26f6995ff mail_transaction_log_view_next() didn't actually stop at the end of view
Timo Sirainen <tss@iki.fi>
parents: 2331
diff changeset
304
1933
bfdff8c75965 fixes for mmap_disable
Timo Sirainen <tss@iki.fi>
parents: 1922
diff changeset
305 data = buffer_get_data(file->buffer, &file_size);
bfdff8c75965 fixes for mmap_disable
Timo Sirainen <tss@iki.fi>
parents: 1922
diff changeset
306 file_size += file->buffer_offset;
bfdff8c75965 fixes for mmap_disable
Timo Sirainen <tss@iki.fi>
parents: 1922
diff changeset
307
2074
cb5269c052e0 Keep the transaction log view open all the time for index views (not just
Timo Sirainen <tss@iki.fi>
parents: 2050
diff changeset
308 if (view->cur_offset + sizeof(*hdr) > file_size) {
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
309 mail_transaction_log_file_set_corrupted(file,
1933
bfdff8c75965 fixes for mmap_disable
Timo Sirainen <tss@iki.fi>
parents: 1922
diff changeset
310 "offset points outside file "
bfdff8c75965 fixes for mmap_disable
Timo Sirainen <tss@iki.fi>
parents: 1922
diff changeset
311 "(%"PRIuUOFF_T" + %"PRIuSIZE_T" > %"PRIuSIZE_T")",
2074
cb5269c052e0 Keep the transaction log view open all the time for index views (not just
Timo Sirainen <tss@iki.fi>
parents: 2050
diff changeset
312 view->cur_offset, sizeof(*hdr), file_size);
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
313 return -1;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
314 }
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
315
3342
43d4aad84752 Minor error checking fixes.
Timo Sirainen <tss@iki.fi>
parents: 3320
diff changeset
316 i_assert(view->cur_offset >= file->buffer_offset);
2074
cb5269c052e0 Keep the transaction log view open all the time for index views (not just
Timo Sirainen <tss@iki.fi>
parents: 2050
diff changeset
317 hdr = CONST_PTR_OFFSET(data, view->cur_offset - file->buffer_offset);
2115
f720b3f15333 Modifying extra_records should work now.
Timo Sirainen <tss@iki.fi>
parents: 2095
diff changeset
318 data = CONST_PTR_OFFSET(hdr, sizeof(*hdr));
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
319
2407
fed6d07bd8ee Transaction log file is now read-lockless.
Timo Sirainen <tss@iki.fi>
parents: 2392
diff changeset
320 hdr_size = mail_index_offset_to_uint32(hdr->size);
fed6d07bd8ee Transaction log file is now read-lockless.
Timo Sirainen <tss@iki.fi>
parents: 2392
diff changeset
321 if (hdr_size < sizeof(*hdr)) {
2563
5752e5ac88f0 Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents: 2507
diff changeset
322 type_rec = NULL;
5752e5ac88f0 Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents: 2507
diff changeset
323 record_size = 0;
5752e5ac88f0 Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents: 2507
diff changeset
324 } else {
5752e5ac88f0 Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents: 2507
diff changeset
325 type_rec = mail_transaction_type_lookup(hdr->type);
5752e5ac88f0 Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents: 2507
diff changeset
326 if (type_rec != NULL)
5752e5ac88f0 Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents: 2507
diff changeset
327 record_size = type_rec->record_size;
5752e5ac88f0 Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents: 2507
diff changeset
328 else {
5752e5ac88f0 Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents: 2507
diff changeset
329 mail_transaction_log_file_set_corrupted(file,
5752e5ac88f0 Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents: 2507
diff changeset
330 "unknown record type 0x%x",
5752e5ac88f0 Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents: 2507
diff changeset
331 hdr->type & MAIL_TRANSACTION_TYPE_MASK);
5752e5ac88f0 Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents: 2507
diff changeset
332 return -1;
5752e5ac88f0 Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents: 2507
diff changeset
333 }
5752e5ac88f0 Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents: 2507
diff changeset
334 }
5752e5ac88f0 Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents: 2507
diff changeset
335
5752e5ac88f0 Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents: 2507
diff changeset
336 if (hdr_size < sizeof(*hdr) + record_size) {
2407
fed6d07bd8ee Transaction log file is now read-lockless.
Timo Sirainen <tss@iki.fi>
parents: 2392
diff changeset
337 mail_transaction_log_file_set_corrupted(file,
3351
63fc076992bf Added offsets to log file corruption error messages
Timo Sirainen <tss@iki.fi>
parents: 3342
diff changeset
338 "record size too small (type=0x%x, "
63fc076992bf Added offsets to log file corruption error messages
Timo Sirainen <tss@iki.fi>
parents: 3342
diff changeset
339 "offset=%"PRIuUOFF_T", size=%u)",
63fc076992bf Added offsets to log file corruption error messages
Timo Sirainen <tss@iki.fi>
parents: 3342
diff changeset
340 hdr->type & MAIL_TRANSACTION_TYPE_MASK,
63fc076992bf Added offsets to log file corruption error messages
Timo Sirainen <tss@iki.fi>
parents: 3342
diff changeset
341 view->cur_offset, hdr_size);
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
342 return -1;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
343 }
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
344
2563
5752e5ac88f0 Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents: 2507
diff changeset
345 if ((hdr_size - sizeof(*hdr)) % record_size != 0) {
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
346 mail_transaction_log_file_set_corrupted(file,
3351
63fc076992bf Added offsets to log file corruption error messages
Timo Sirainen <tss@iki.fi>
parents: 3342
diff changeset
347 "record size wrong (type 0x%x, "
3649
8c63af0ab91a Fixed some printf-type mismatches
Timo Sirainen <tss@iki.fi>
parents: 3351
diff changeset
348 "offset=%"PRIuUOFF_T", size=%"PRIuSIZE_T" %% %u != 0)",
2563
5752e5ac88f0 Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents: 2507
diff changeset
349 hdr->type & MAIL_TRANSACTION_TYPE_MASK,
3351
63fc076992bf Added offsets to log file corruption error messages
Timo Sirainen <tss@iki.fi>
parents: 3342
diff changeset
350 view->cur_offset, (hdr_size - sizeof(*hdr)),
63fc076992bf Added offsets to log file corruption error messages
Timo Sirainen <tss@iki.fi>
parents: 3342
diff changeset
351 record_size);
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
352 return -1;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
353 }
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
354
3342
43d4aad84752 Minor error checking fixes.
Timo Sirainen <tss@iki.fi>
parents: 3320
diff changeset
355 if (file_size - view->cur_offset < hdr_size) {
43d4aad84752 Minor error checking fixes.
Timo Sirainen <tss@iki.fi>
parents: 3320
diff changeset
356 mail_transaction_log_file_set_corrupted(file,
3351
63fc076992bf Added offsets to log file corruption error messages
Timo Sirainen <tss@iki.fi>
parents: 3342
diff changeset
357 "record size too large (type=0x%x, "
63fc076992bf Added offsets to log file corruption error messages
Timo Sirainen <tss@iki.fi>
parents: 3342
diff changeset
358 "offset=%"PRIuUOFF_T", size=%u, end=%"PRIuSIZE_T")",
3342
43d4aad84752 Minor error checking fixes.
Timo Sirainen <tss@iki.fi>
parents: 3320
diff changeset
359 hdr->type & MAIL_TRANSACTION_TYPE_MASK,
43d4aad84752 Minor error checking fixes.
Timo Sirainen <tss@iki.fi>
parents: 3320
diff changeset
360 view->cur_offset, hdr_size, file_size);
43d4aad84752 Minor error checking fixes.
Timo Sirainen <tss@iki.fi>
parents: 3320
diff changeset
361 return -1;
43d4aad84752 Minor error checking fixes.
Timo Sirainen <tss@iki.fi>
parents: 3320
diff changeset
362 }
43d4aad84752 Minor error checking fixes.
Timo Sirainen <tss@iki.fi>
parents: 3320
diff changeset
363
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
364 if ((hdr->type & MAIL_TRANSACTION_EXPUNGE) != 0) {
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
365 if ((hdr->type & MAIL_TRANSACTION_TYPE_MASK) !=
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
366 (MAIL_TRANSACTION_EXPUNGE|MAIL_TRANSACTION_EXPUNGE_PROT)) {
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
367 mail_transaction_log_file_set_corrupted(file,
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
368 "found expunge without protection mask");
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
369 return -1;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
370 }
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
371 } else if ((hdr->type & MAIL_TRANSACTION_TYPE_MASK) != type_rec->type) {
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
372 mail_transaction_log_file_set_corrupted(file,
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
373 "extra bits in header type: 0x%x",
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
374 hdr->type & MAIL_TRANSACTION_TYPE_MASK);
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
375 return -1;
2671
3b70ddb51771 Renamed "extra record info" and variations of it to "extension" or "ext" in
Timo Sirainen <tss@iki.fi>
parents: 2616
diff changeset
376 } else if (hdr->type == MAIL_TRANSACTION_EXT_INTRO) {
2683
d41c42a7bf1e Index extensions can now specify record alignment, and it's possible to
Timo Sirainen <tss@iki.fi>
parents: 2671
diff changeset
377 const struct mail_transaction_ext_intro *intro;
d41c42a7bf1e Index extensions can now specify record alignment, and it's possible to
Timo Sirainen <tss@iki.fi>
parents: 2671
diff changeset
378 uint32_t i;
d41c42a7bf1e Index extensions can now specify record alignment, and it's possible to
Timo Sirainen <tss@iki.fi>
parents: 2671
diff changeset
379
2701
Timo Sirainen <tss@iki.fi>
parents: 2683
diff changeset
380 for (i = 0; i < hdr_size; ) {
Timo Sirainen <tss@iki.fi>
parents: 2683
diff changeset
381 if (i + sizeof(*intro) > hdr_size) {
2683
d41c42a7bf1e Index extensions can now specify record alignment, and it's possible to
Timo Sirainen <tss@iki.fi>
parents: 2671
diff changeset
382 /* should be just extra padding */
d41c42a7bf1e Index extensions can now specify record alignment, and it's possible to
Timo Sirainen <tss@iki.fi>
parents: 2671
diff changeset
383 break;
d41c42a7bf1e Index extensions can now specify record alignment, and it's possible to
Timo Sirainen <tss@iki.fi>
parents: 2671
diff changeset
384 }
2115
f720b3f15333 Modifying extra_records should work now.
Timo Sirainen <tss@iki.fi>
parents: 2095
diff changeset
385
2683
d41c42a7bf1e Index extensions can now specify record alignment, and it's possible to
Timo Sirainen <tss@iki.fi>
parents: 2671
diff changeset
386 intro = CONST_PTR_OFFSET(data, i);
d41c42a7bf1e Index extensions can now specify record alignment, and it's possible to
Timo Sirainen <tss@iki.fi>
parents: 2671
diff changeset
387 if (intro->name_size >
d41c42a7bf1e Index extensions can now specify record alignment, and it's possible to
Timo Sirainen <tss@iki.fi>
parents: 2671
diff changeset
388 hdr_size - sizeof(*hdr) - sizeof(*intro)) {
d41c42a7bf1e Index extensions can now specify record alignment, and it's possible to
Timo Sirainen <tss@iki.fi>
parents: 2671
diff changeset
389 mail_transaction_log_file_set_corrupted(file,
d41c42a7bf1e Index extensions can now specify record alignment, and it's possible to
Timo Sirainen <tss@iki.fi>
parents: 2671
diff changeset
390 "extension intro: name_size too large");
d41c42a7bf1e Index extensions can now specify record alignment, and it's possible to
Timo Sirainen <tss@iki.fi>
parents: 2671
diff changeset
391 return -1;
d41c42a7bf1e Index extensions can now specify record alignment, and it's possible to
Timo Sirainen <tss@iki.fi>
parents: 2671
diff changeset
392 }
d41c42a7bf1e Index extensions can now specify record alignment, and it's possible to
Timo Sirainen <tss@iki.fi>
parents: 2671
diff changeset
393
d41c42a7bf1e Index extensions can now specify record alignment, and it's possible to
Timo Sirainen <tss@iki.fi>
parents: 2671
diff changeset
394 i += sizeof(*intro) + intro->name_size;
2115
f720b3f15333 Modifying extra_records should work now.
Timo Sirainen <tss@iki.fi>
parents: 2095
diff changeset
395 }
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
396 }
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
397
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
398 *hdr_r = hdr;
2115
f720b3f15333 Modifying extra_records should work now.
Timo Sirainen <tss@iki.fi>
parents: 2095
diff changeset
399 *data_r = data;
2407
fed6d07bd8ee Transaction log file is now read-lockless.
Timo Sirainen <tss@iki.fi>
parents: 2392
diff changeset
400 view->cur_offset += hdr_size;
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
401 return 1;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
402 }
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
403
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
404 int mail_transaction_log_view_next(struct mail_transaction_log_view *view,
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
405 const struct mail_transaction_header **hdr_r,
3863
55df57c028d4 Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents: 3832
diff changeset
406 const void **data_r, bool *skipped_r)
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
407 {
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
408 const struct mail_transaction_header *hdr;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
409 const void *data;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
410 int ret = 0;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
411
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
412 if (skipped_r != NULL)
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
413 *skipped_r = FALSE;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
414 if (view->broken)
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
415 return -1;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
416
2702
d6f25d0e104a Don't complain about corruption when there is none.
Timo Sirainen <tss@iki.fi>
parents: 2701
diff changeset
417 while ((ret = log_view_get_next(view, &hdr, &data)) > 0) {
2882
dda3fe468ea3 When view was synced without expunges, we didn't actually sync the expunges
Timo Sirainen <tss@iki.fi>
parents: 2819
diff changeset
418 if ((view->type_mask & hdr->type) != 0) {
dda3fe468ea3 When view was synced without expunges, we didn't actually sync the expunges
Timo Sirainen <tss@iki.fi>
parents: 2819
diff changeset
419 /* looks like this is within our mask, but expunge
dda3fe468ea3 When view was synced without expunges, we didn't actually sync the expunges
Timo Sirainen <tss@iki.fi>
parents: 2819
diff changeset
420 protection may mess up the check. */
dda3fe468ea3 When view was synced without expunges, we didn't actually sync the expunges
Timo Sirainen <tss@iki.fi>
parents: 2819
diff changeset
421 if ((hdr->type & MAIL_TRANSACTION_EXPUNGE) == 0 ||
dda3fe468ea3 When view was synced without expunges, we didn't actually sync the expunges
Timo Sirainen <tss@iki.fi>
parents: 2819
diff changeset
422 (view->type_mask & MAIL_TRANSACTION_EXPUNGE) != 0)
dda3fe468ea3 When view was synced without expunges, we didn't actually sync the expunges
Timo Sirainen <tss@iki.fi>
parents: 2819
diff changeset
423 break;
dda3fe468ea3 When view was synced without expunges, we didn't actually sync the expunges
Timo Sirainen <tss@iki.fi>
parents: 2819
diff changeset
424 }
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
425
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
426 /* we don't want this record */
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
427 if (skipped_r != NULL)
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
428 *skipped_r = TRUE;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
429
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
430 /* FIXME: hide flag/cache updates for appends if
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
431 append isn't in mask */
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
432 }
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
433
2563
5752e5ac88f0 Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents: 2507
diff changeset
434 if (ret < 0) {
5752e5ac88f0 Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents: 2507
diff changeset
435 view->cur_offset = view->cur->sync_offset;
5752e5ac88f0 Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents: 2507
diff changeset
436 return -1;
5752e5ac88f0 Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents: 2507
diff changeset
437 }
5752e5ac88f0 Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents: 2507
diff changeset
438 if (ret == 0)
5752e5ac88f0 Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents: 2507
diff changeset
439 return 0;
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
440
2407
fed6d07bd8ee Transaction log file is now read-lockless.
Timo Sirainen <tss@iki.fi>
parents: 2392
diff changeset
441 view->tmp_hdr = *hdr;
fed6d07bd8ee Transaction log file is now read-lockless.
Timo Sirainen <tss@iki.fi>
parents: 2392
diff changeset
442 view->tmp_hdr.size =
fed6d07bd8ee Transaction log file is now read-lockless.
Timo Sirainen <tss@iki.fi>
parents: 2392
diff changeset
443 mail_index_offset_to_uint32(view->tmp_hdr.size) - sizeof(*hdr);
fed6d07bd8ee Transaction log file is now read-lockless.
Timo Sirainen <tss@iki.fi>
parents: 2392
diff changeset
444 i_assert(view->tmp_hdr.size != 0);
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
445
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
446 if ((hdr->type & MAIL_TRANSACTION_EXPUNGE) != 0) {
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
447 /* hide expunge protection */
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
448 view->tmp_hdr.type &= ~MAIL_TRANSACTION_EXPUNGE_PROT;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
449 }
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
450
2407
fed6d07bd8ee Transaction log file is now read-lockless.
Timo Sirainen <tss@iki.fi>
parents: 2392
diff changeset
451 *hdr_r = &view->tmp_hdr;
fed6d07bd8ee Transaction log file is now read-lockless.
Timo Sirainen <tss@iki.fi>
parents: 2392
diff changeset
452 *data_r = data;
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
453 return 1;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
454 }