annotate src/lib-index/mail-transaction-log.h @ 9354:687ac828b964 HEAD

lib-index: modseqs weren't tracked properly within session when changes were done.
author Timo Sirainen <tss@iki.fi>
date Tue, 01 Sep 2009 13:05:03 -0400
parents 9445831aebc0
children e5d38150be58
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6410
e4eb71ae8e96 Changed .h ifdef/defines to use <NAME>_H format.
Timo Sirainen <tss@iki.fi>
parents: 5849
diff changeset
1 #ifndef MAIL_TRANSACTION_LOG_H
e4eb71ae8e96 Changed .h ifdef/defines to use <NAME>_H format.
Timo Sirainen <tss@iki.fi>
parents: 5849
diff changeset
2 #define MAIL_TRANSACTION_LOG_H
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
3
7812
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7573
diff changeset
4 struct mail_index;
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7573
diff changeset
5 struct mail_index_transaction;
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7573
diff changeset
6
9041
c8d63b42e9cc Added mail_index_unlink().
Timo Sirainen <tss@iki.fi>
parents: 9020
diff changeset
7 #define MAIL_TRANSACTION_LOG_SUFFIX ".log"
c8d63b42e9cc Added mail_index_unlink().
Timo Sirainen <tss@iki.fi>
parents: 9020
diff changeset
8
3169
ec17099a6490 Added versioning to transaction log header. Added create_stamp to its
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
9 #define MAIL_TRANSACTION_LOG_MAJOR_VERSION 1
8129
612eb505775f Write CPU endianess to transaction log header and check it's correct when reading.
Timo Sirainen <tss@iki.fi>
parents: 7895
diff changeset
10 #define MAIL_TRANSACTION_LOG_MINOR_VERSION 2
3169
ec17099a6490 Added versioning to transaction log header. Added create_stamp to its
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
11 #define MAIL_TRANSACTION_LOG_HEADER_MIN_SIZE 24
ec17099a6490 Added versioning to transaction log header. Added create_stamp to its
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
12
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
13 struct mail_transaction_log_header {
3169
ec17099a6490 Added versioning to transaction log header. Added create_stamp to its
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
14 uint8_t major_version;
ec17099a6490 Added versioning to transaction log header. Added create_stamp to its
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
15 uint8_t minor_version;
ec17099a6490 Added versioning to transaction log header. Added create_stamp to its
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
16 uint16_t hdr_size;
ec17099a6490 Added versioning to transaction log header. Added create_stamp to its
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
17
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
18 uint32_t indexid;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
19 uint32_t file_seq;
1940
Timo Sirainen <tss@iki.fi>
parents: 1935
diff changeset
20 uint32_t prev_file_seq;
1935
ec4d5ff99f6e Don't modify index file when creating new transaction log.
Timo Sirainen <tss@iki.fi>
parents: 1915
diff changeset
21 uint32_t prev_file_offset;
3169
ec17099a6490 Added versioning to transaction log header. Added create_stamp to its
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
22 uint32_t create_stamp;
8266
47edfe6ad295 Comment update.
Timo Sirainen <tss@iki.fi>
parents: 8135
diff changeset
23 uint64_t initial_modseq; /* v1.1+ (note: log's major/minor version) */
8129
612eb505775f Write CPU endianess to transaction log header and check it's correct when reading.
Timo Sirainen <tss@iki.fi>
parents: 7895
diff changeset
24
612eb505775f Write CPU endianess to transaction log header and check it's correct when reading.
Timo Sirainen <tss@iki.fi>
parents: 7895
diff changeset
25 uint8_t compat_flags; /* enum mail_index_header_compat_flags, v1.2+ */
612eb505775f Write CPU endianess to transaction log header and check it's correct when reading.
Timo Sirainen <tss@iki.fi>
parents: 7895
diff changeset
26 uint8_t unused[3];
8135
0be9c476acdd Added padding to struct mail_transaction_log_header so it's 64bit aligned.
Timo Sirainen <tss@iki.fi>
parents: 8130
diff changeset
27 uint32_t unused2; /* so that this struct is 64bit aligned */
1915
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
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
30 enum mail_transaction_type {
2115
f720b3f15333 Modifying extra_records should work now.
Timo Sirainen <tss@iki.fi>
parents: 2074
diff changeset
31 MAIL_TRANSACTION_EXPUNGE = 0x00000001,
f720b3f15333 Modifying extra_records should work now.
Timo Sirainen <tss@iki.fi>
parents: 2074
diff changeset
32 MAIL_TRANSACTION_APPEND = 0x00000002,
f720b3f15333 Modifying extra_records should work now.
Timo Sirainen <tss@iki.fi>
parents: 2074
diff changeset
33 MAIL_TRANSACTION_FLAG_UPDATE = 0x00000004,
2201
7bdef5ea4591 Several fixes and cleanups to cache file code, still badly broken
Timo Sirainen <tss@iki.fi>
parents: 2115
diff changeset
34 MAIL_TRANSACTION_HEADER_UPDATE = 0x00000020,
2671
3b70ddb51771 Renamed "extra record info" and variations of it to "extension" or "ext" in
Timo Sirainen <tss@iki.fi>
parents: 2563
diff changeset
35 MAIL_TRANSACTION_EXT_INTRO = 0x00000040,
3b70ddb51771 Renamed "extra record info" and variations of it to "extension" or "ext" in
Timo Sirainen <tss@iki.fi>
parents: 2563
diff changeset
36 MAIL_TRANSACTION_EXT_RESET = 0x00000080,
3b70ddb51771 Renamed "extra record info" and variations of it to "extension" or "ext" in
Timo Sirainen <tss@iki.fi>
parents: 2563
diff changeset
37 MAIL_TRANSACTION_EXT_HDR_UPDATE = 0x00000100,
3b70ddb51771 Renamed "extra record info" and variations of it to "extension" or "ext" in
Timo Sirainen <tss@iki.fi>
parents: 2563
diff changeset
38 MAIL_TRANSACTION_EXT_REC_UPDATE = 0x00000200,
3016
61c8d205d887 Initial support for keywords. Syncing to mbox/maildir doesn't work yet.
Timo Sirainen <tss@iki.fi>
parents: 2853
diff changeset
39 MAIL_TRANSACTION_KEYWORD_UPDATE = 0x00000400,
3138
fbe844061fe2 Internal changes in how keywords are handled. struct mail_keywords isn't
Timo Sirainen <tss@iki.fi>
parents: 3111
diff changeset
40 MAIL_TRANSACTION_KEYWORD_RESET = 0x00000800,
9318
9445831aebc0 lib-index: Added support for reading new records generated by Dovecot v2.0.
Timo Sirainen <tss@iki.fi>
parents: 9041
diff changeset
41 MAIL_TRANSACTION_EXPUNGE_GUID = 0x00002000,
9445831aebc0 lib-index: Added support for reading new records generated by Dovecot v2.0.
Timo Sirainen <tss@iki.fi>
parents: 9041
diff changeset
42 MAIL_TRANSACTION_UID_UPDATE = 0x00004000,
9445831aebc0 lib-index: Added support for reading new records generated by Dovecot v2.0.
Timo Sirainen <tss@iki.fi>
parents: 9041
diff changeset
43 MAIL_TRANSACTION_MODSEQ_UPDATE = 0x00008000,
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
44
2115
f720b3f15333 Modifying extra_records should work now.
Timo Sirainen <tss@iki.fi>
parents: 2074
diff changeset
45 MAIL_TRANSACTION_TYPE_MASK = 0x0000ffff,
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
46
5749
420a386fa27a int/ext/mailbox sync offset changes: Combined mailbox and int offsets to
Timo Sirainen <tss@iki.fi>
parents: 5747
diff changeset
47 #define MAIL_TRANSACTION_EXT_MASK \
420a386fa27a int/ext/mailbox sync offset changes: Combined mailbox and int offsets to
Timo Sirainen <tss@iki.fi>
parents: 5747
diff changeset
48 (MAIL_TRANSACTION_EXT_INTRO | MAIL_TRANSACTION_EXT_RESET | \
420a386fa27a int/ext/mailbox sync offset changes: Combined mailbox and int offsets to
Timo Sirainen <tss@iki.fi>
parents: 5747
diff changeset
49 MAIL_TRANSACTION_EXT_HDR_UPDATE | MAIL_TRANSACTION_EXT_REC_UPDATE)
420a386fa27a int/ext/mailbox sync offset changes: Combined mailbox and int offsets to
Timo Sirainen <tss@iki.fi>
parents: 5747
diff changeset
50
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
51 /* since we'll expunge mails based on data read from transaction log,
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
52 try to avoid the possibility of corrupted transaction log expunging
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
53 messages. this value is ORed to the actual MAIL_TRANSACTION_EXPUNGE
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
54 flag. if it's not present, assume corrupted log. */
2115
f720b3f15333 Modifying extra_records should work now.
Timo Sirainen <tss@iki.fi>
parents: 2074
diff changeset
55 MAIL_TRANSACTION_EXPUNGE_PROT = 0x0000cd90,
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
56
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
57 /* Mailbox synchronization noticed this change. */
2115
f720b3f15333 Modifying extra_records should work now.
Timo Sirainen <tss@iki.fi>
parents: 2074
diff changeset
58 MAIL_TRANSACTION_EXTERNAL = 0x10000000
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
59 };
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
60
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
61 struct mail_transaction_header {
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
62 uint32_t size;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
63 uint32_t type; /* enum mail_transaction_type */
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
64 };
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
65
9318
9445831aebc0 lib-index: Added support for reading new records generated by Dovecot v2.0.
Timo Sirainen <tss@iki.fi>
parents: 9041
diff changeset
66 struct mail_transaction_uid_update {
9445831aebc0 lib-index: Added support for reading new records generated by Dovecot v2.0.
Timo Sirainen <tss@iki.fi>
parents: 9041
diff changeset
67 uint32_t old_uid, new_uid;
9445831aebc0 lib-index: Added support for reading new records generated by Dovecot v2.0.
Timo Sirainen <tss@iki.fi>
parents: 9041
diff changeset
68 };
9445831aebc0 lib-index: Added support for reading new records generated by Dovecot v2.0.
Timo Sirainen <tss@iki.fi>
parents: 9041
diff changeset
69
9445831aebc0 lib-index: Added support for reading new records generated by Dovecot v2.0.
Timo Sirainen <tss@iki.fi>
parents: 9041
diff changeset
70 struct mail_transaction_modseq_update {
9445831aebc0 lib-index: Added support for reading new records generated by Dovecot v2.0.
Timo Sirainen <tss@iki.fi>
parents: 9041
diff changeset
71 uint32_t uid;
9445831aebc0 lib-index: Added support for reading new records generated by Dovecot v2.0.
Timo Sirainen <tss@iki.fi>
parents: 9041
diff changeset
72 /* don't use uint64_t here. it adds extra 32 bits of paddiong and also
9445831aebc0 lib-index: Added support for reading new records generated by Dovecot v2.0.
Timo Sirainen <tss@iki.fi>
parents: 9041
diff changeset
73 causes problems with CPUs that require alignment */
9445831aebc0 lib-index: Added support for reading new records generated by Dovecot v2.0.
Timo Sirainen <tss@iki.fi>
parents: 9041
diff changeset
74 uint32_t modseq_low32;
9445831aebc0 lib-index: Added support for reading new records generated by Dovecot v2.0.
Timo Sirainen <tss@iki.fi>
parents: 9041
diff changeset
75 uint32_t modseq_high32;
9445831aebc0 lib-index: Added support for reading new records generated by Dovecot v2.0.
Timo Sirainen <tss@iki.fi>
parents: 9041
diff changeset
76 };
9445831aebc0 lib-index: Added support for reading new records generated by Dovecot v2.0.
Timo Sirainen <tss@iki.fi>
parents: 9041
diff changeset
77
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
78 struct mail_transaction_expunge {
2033
4f6b1118a53d Transaction log contains only UIDs now, no more sequences which just mess up
Timo Sirainen <tss@iki.fi>
parents: 2009
diff changeset
79 uint32_t uid1, uid2;
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
80 };
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
81
9318
9445831aebc0 lib-index: Added support for reading new records generated by Dovecot v2.0.
Timo Sirainen <tss@iki.fi>
parents: 9041
diff changeset
82 struct mail_transaction_expunge_guid {
9445831aebc0 lib-index: Added support for reading new records generated by Dovecot v2.0.
Timo Sirainen <tss@iki.fi>
parents: 9041
diff changeset
83 uint32_t uid;
9445831aebc0 lib-index: Added support for reading new records generated by Dovecot v2.0.
Timo Sirainen <tss@iki.fi>
parents: 9041
diff changeset
84 uint8_t guid_128[16];
9445831aebc0 lib-index: Added support for reading new records generated by Dovecot v2.0.
Timo Sirainen <tss@iki.fi>
parents: 9041
diff changeset
85 };
9445831aebc0 lib-index: Added support for reading new records generated by Dovecot v2.0.
Timo Sirainen <tss@iki.fi>
parents: 9041
diff changeset
86
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
87 struct mail_transaction_flag_update {
2033
4f6b1118a53d Transaction log contains only UIDs now, no more sequences which just mess up
Timo Sirainen <tss@iki.fi>
parents: 2009
diff changeset
88 uint32_t uid1, uid2;
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
89 uint8_t add_flags;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
90 uint8_t remove_flags;
3111
b1eaafa49f53 Added padding field explicitly for struct mail_transaction_flag_update. It
Timo Sirainen <tss@iki.fi>
parents: 3016
diff changeset
91 uint16_t padding;
3016
61c8d205d887 Initial support for keywords. Syncing to mbox/maildir doesn't work yet.
Timo Sirainen <tss@iki.fi>
parents: 2853
diff changeset
92 };
61c8d205d887 Initial support for keywords. Syncing to mbox/maildir doesn't work yet.
Timo Sirainen <tss@iki.fi>
parents: 2853
diff changeset
93
61c8d205d887 Initial support for keywords. Syncing to mbox/maildir doesn't work yet.
Timo Sirainen <tss@iki.fi>
parents: 2853
diff changeset
94 struct mail_transaction_keyword_update {
3138
fbe844061fe2 Internal changes in how keywords are handled. struct mail_keywords isn't
Timo Sirainen <tss@iki.fi>
parents: 3111
diff changeset
95 uint8_t modify_type; /* enum modify_type : MODIFY_ADD / MODIFY_REMOVE */
3016
61c8d205d887 Initial support for keywords. Syncing to mbox/maildir doesn't work yet.
Timo Sirainen <tss@iki.fi>
parents: 2853
diff changeset
96 uint8_t padding;
3138
fbe844061fe2 Internal changes in how keywords are handled. struct mail_keywords isn't
Timo Sirainen <tss@iki.fi>
parents: 3111
diff changeset
97 uint16_t name_size;
fbe844061fe2 Internal changes in how keywords are handled. struct mail_keywords isn't
Timo Sirainen <tss@iki.fi>
parents: 3111
diff changeset
98 /* unsigned char name[];
3016
61c8d205d887 Initial support for keywords. Syncing to mbox/maildir doesn't work yet.
Timo Sirainen <tss@iki.fi>
parents: 2853
diff changeset
99 array of { uint32_t uid1, uid2; }
61c8d205d887 Initial support for keywords. Syncing to mbox/maildir doesn't work yet.
Timo Sirainen <tss@iki.fi>
parents: 2853
diff changeset
100 */
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
101 };
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
102
3138
fbe844061fe2 Internal changes in how keywords are handled. struct mail_keywords isn't
Timo Sirainen <tss@iki.fi>
parents: 3111
diff changeset
103 struct mail_transaction_keyword_reset {
fbe844061fe2 Internal changes in how keywords are handled. struct mail_keywords isn't
Timo Sirainen <tss@iki.fi>
parents: 3111
diff changeset
104 uint32_t uid1, uid2;
fbe844061fe2 Internal changes in how keywords are handled. struct mail_keywords isn't
Timo Sirainen <tss@iki.fi>
parents: 3111
diff changeset
105 };
fbe844061fe2 Internal changes in how keywords are handled. struct mail_keywords isn't
Timo Sirainen <tss@iki.fi>
parents: 3111
diff changeset
106
2050
ee1095ccfd23 Index header changes now go through transaction log. Removed the kludgy
Timo Sirainen <tss@iki.fi>
parents: 2033
diff changeset
107 struct mail_transaction_header_update {
ee1095ccfd23 Index header changes now go through transaction log. Removed the kludgy
Timo Sirainen <tss@iki.fi>
parents: 2033
diff changeset
108 uint16_t offset;
ee1095ccfd23 Index header changes now go through transaction log. Removed the kludgy
Timo Sirainen <tss@iki.fi>
parents: 2033
diff changeset
109 uint16_t size;
2410
c7c886199f28 Small cleanups.
Timo Sirainen <tss@iki.fi>
parents: 2407
diff changeset
110 /* unsigned char data[]; */
2050
ee1095ccfd23 Index header changes now go through transaction log. Removed the kludgy
Timo Sirainen <tss@iki.fi>
parents: 2033
diff changeset
111 };
ee1095ccfd23 Index header changes now go through transaction log. Removed the kludgy
Timo Sirainen <tss@iki.fi>
parents: 2033
diff changeset
112
7895
5bedea448cf9 Mail index extension introductions now add a "no resizes" flag to the
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
113 enum {
8130
b97c3be33b04 Replaced "no extension resizing" flag with "no extension shrinking".
Timo Sirainen <tss@iki.fi>
parents: 8129
diff changeset
114 /* Don't shrink hdr_size, record_size or record_align but grow them
b97c3be33b04 Replaced "no extension resizing" flag with "no extension shrinking".
Timo Sirainen <tss@iki.fi>
parents: 8129
diff changeset
115 if necessary. */
b97c3be33b04 Replaced "no extension resizing" flag with "no extension shrinking".
Timo Sirainen <tss@iki.fi>
parents: 8129
diff changeset
116 MAIL_TRANSACTION_EXT_INTRO_FLAG_NO_SHRINK = 0x01
7895
5bedea448cf9 Mail index extension introductions now add a "no resizes" flag to the
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
117 };
5bedea448cf9 Mail index extension introductions now add a "no resizes" flag to the
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
118
2671
3b70ddb51771 Renamed "extra record info" and variations of it to "extension" or "ext" in
Timo Sirainen <tss@iki.fi>
parents: 2563
diff changeset
119 struct mail_transaction_ext_intro {
2762
a1c7e92c1839 New way of handling extension introductions in transaction log.
Timo Sirainen <tss@iki.fi>
parents: 2683
diff changeset
120 /* old extension: set ext_id. don't set name.
a1c7e92c1839 New way of handling extension introductions in transaction log.
Timo Sirainen <tss@iki.fi>
parents: 2683
diff changeset
121 new extension: ext_id = (uint32_t)-1. give name. */
a1c7e92c1839 New way of handling extension introductions in transaction log.
Timo Sirainen <tss@iki.fi>
parents: 2683
diff changeset
122 uint32_t ext_id;
2853
512dd7d76cdc Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents: 2762
diff changeset
123 uint32_t reset_id;
2563
5752e5ac88f0 Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents: 2410
diff changeset
124 uint32_t hdr_size;
5752e5ac88f0 Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents: 2410
diff changeset
125 uint16_t record_size;
2683
d41c42a7bf1e Index extensions can now specify record alignment, and it's possible to
Timo Sirainen <tss@iki.fi>
parents: 2671
diff changeset
126 uint16_t record_align;
7895
5bedea448cf9 Mail index extension introductions now add a "no resizes" flag to the
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
127 uint16_t flags;
2563
5752e5ac88f0 Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents: 2410
diff changeset
128 uint16_t name_size;
5752e5ac88f0 Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents: 2410
diff changeset
129 /* unsigned char name[]; */
5752e5ac88f0 Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents: 2410
diff changeset
130 };
5752e5ac88f0 Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents: 2410
diff changeset
131
2853
512dd7d76cdc Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents: 2762
diff changeset
132 struct mail_transaction_ext_reset {
512dd7d76cdc Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents: 2762
diff changeset
133 uint32_t new_reset_id;
7563
6de1aed24ce5 Added mail_index_ext_reset_inc() to atomically increase extension's
Timo Sirainen <tss@iki.fi>
parents: 6458
diff changeset
134 uint8_t preserve_data;
6de1aed24ce5 Added mail_index_ext_reset_inc() to atomically increase extension's
Timo Sirainen <tss@iki.fi>
parents: 6458
diff changeset
135 uint8_t unused_padding[3];
2853
512dd7d76cdc Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents: 2762
diff changeset
136 };
512dd7d76cdc Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents: 2762
diff changeset
137
2762
a1c7e92c1839 New way of handling extension introductions in transaction log.
Timo Sirainen <tss@iki.fi>
parents: 2683
diff changeset
138 /* these are set for the last ext_intro */
2671
3b70ddb51771 Renamed "extra record info" and variations of it to "extension" or "ext" in
Timo Sirainen <tss@iki.fi>
parents: 2563
diff changeset
139 struct mail_transaction_ext_hdr_update {
2563
5752e5ac88f0 Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents: 2410
diff changeset
140 uint16_t offset;
5752e5ac88f0 Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents: 2410
diff changeset
141 uint16_t size;
5752e5ac88f0 Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents: 2410
diff changeset
142 /* unsigned char data[]; */
5752e5ac88f0 Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents: 2410
diff changeset
143 };
5752e5ac88f0 Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents: 2410
diff changeset
144
2671
3b70ddb51771 Renamed "extra record info" and variations of it to "extension" or "ext" in
Timo Sirainen <tss@iki.fi>
parents: 2563
diff changeset
145 struct mail_transaction_ext_rec_update {
2115
f720b3f15333 Modifying extra_records should work now.
Timo Sirainen <tss@iki.fi>
parents: 2074
diff changeset
146 uint32_t uid;
2410
c7c886199f28 Small cleanups.
Timo Sirainen <tss@iki.fi>
parents: 2407
diff changeset
147 /* unsigned char data[]; */
2115
f720b3f15333 Modifying extra_records should work now.
Timo Sirainen <tss@iki.fi>
parents: 2074
diff changeset
148 };
f720b3f15333 Modifying extra_records should work now.
Timo Sirainen <tss@iki.fi>
parents: 2074
diff changeset
149
5747
c71f611bbffc Removed syncs_done array. Instead track appends and expunges separately.
Timo Sirainen <tss@iki.fi>
parents: 5728
diff changeset
150 #define LOG_IS_BEFORE(seq1, offset1, seq2, offset2) \
c71f611bbffc Removed syncs_done array. Instead track appends and expunges separately.
Timo Sirainen <tss@iki.fi>
parents: 5728
diff changeset
151 (((offset1) < (offset2) && (seq1) == (seq2)) || (seq1) < (seq2))
c71f611bbffc Removed syncs_done array. Instead track appends and expunges separately.
Timo Sirainen <tss@iki.fi>
parents: 5728
diff changeset
152
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
153 struct mail_transaction_log *
5689
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5656
diff changeset
154 mail_transaction_log_alloc(struct mail_index *index);
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5656
diff changeset
155 void mail_transaction_log_free(struct mail_transaction_log **log);
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5656
diff changeset
156
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5656
diff changeset
157 /* Open the transaction log. Returns 1 if ok, 0 if file doesn't exist or it's
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5656
diff changeset
158 is corrupted, -1 if there was some I/O error. */
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5656
diff changeset
159 int mail_transaction_log_open(struct mail_transaction_log *log);
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5656
diff changeset
160 /* Create, or recreate, the transaction log. Returns 0 if ok, -1 if error. */
7573
de08cc81da73 Fixes to handling races in initial index creation.
Timo Sirainen <tss@iki.fi>
parents: 7563
diff changeset
161 int mail_transaction_log_create(struct mail_transaction_log *log, bool reset);
5689
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5656
diff changeset
162 /* Close all the open transactions log files. */
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5656
diff changeset
163 void mail_transaction_log_close(struct mail_transaction_log *log);
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
164
5819
4ea31bf18a56 Handle indexid changes better.
Timo Sirainen <tss@iki.fi>
parents: 5749
diff changeset
165 /* Notify of indexid change */
4ea31bf18a56 Handle indexid changes better.
Timo Sirainen <tss@iki.fi>
parents: 5749
diff changeset
166 void mail_transaction_log_indexid_changed(struct mail_transaction_log *log);
4ea31bf18a56 Handle indexid changes better.
Timo Sirainen <tss@iki.fi>
parents: 5749
diff changeset
167
5689
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5656
diff changeset
168 /* Returns the file seq/offset where the mailbox is currently synced at.
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5656
diff changeset
169 Since the log is rotated only when mailbox is fully synced, the sequence
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5656
diff changeset
170 points always to the latest file. This function doesn't actually find the
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5656
diff changeset
171 latest sync position, so you'll need to use eg. log_view_set() before
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5656
diff changeset
172 calling this. */
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5656
diff changeset
173 void mail_transaction_log_get_mailbox_sync_pos(struct mail_transaction_log *log,
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5656
diff changeset
174 uint32_t *file_seq_r,
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5656
diff changeset
175 uoff_t *file_offset_r);
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5656
diff changeset
176 /* Set the current mailbox sync position. file_seq must always be the latest
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5656
diff changeset
177 log file's sequence. The offset written automatically to the log when
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5656
diff changeset
178 other transactions are being written. */
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5656
diff changeset
179 void mail_transaction_log_set_mailbox_sync_pos(struct mail_transaction_log *log,
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5656
diff changeset
180 uint32_t file_seq,
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5656
diff changeset
181 uoff_t file_offset);
3833
318c70c1d4ec Beginnings of fallbacking to in-memory indexes when write fails with "out of
Timo Sirainen <tss@iki.fi>
parents: 3832
diff changeset
182
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
183 struct mail_transaction_log_view *
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
184 mail_transaction_log_view_open(struct mail_transaction_log *log);
3879
928229f8b3e6 deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
185 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
186
5849
a9df50952600 Added support for resetting index.
Timo Sirainen <tss@iki.fi>
parents: 5819
diff changeset
187 /* Set view boundaries. Returns -1 if error, 0 if files are lost, 1 if ok.
a9df50952600 Added support for resetting index.
Timo Sirainen <tss@iki.fi>
parents: 5819
diff changeset
188 reset_r=TRUE if the whole index should be reset before applying any
a9df50952600 Added support for resetting index.
Timo Sirainen <tss@iki.fi>
parents: 5819
diff changeset
189 changes. */
a9df50952600 Added support for resetting index.
Timo Sirainen <tss@iki.fi>
parents: 5819
diff changeset
190 int mail_transaction_log_view_set(struct mail_transaction_log_view *view,
a9df50952600 Added support for resetting index.
Timo Sirainen <tss@iki.fi>
parents: 5819
diff changeset
191 uint32_t min_file_seq, uoff_t min_file_offset,
a9df50952600 Added support for resetting index.
Timo Sirainen <tss@iki.fi>
parents: 5819
diff changeset
192 uint32_t max_file_seq, uoff_t max_file_offset,
a9df50952600 Added support for resetting index.
Timo Sirainen <tss@iki.fi>
parents: 5819
diff changeset
193 bool *reset_r);
9020
a6779d086785 mail_transaction_log_view_clear() should keep oldest_file_seq and newer referenced.
Timo Sirainen <tss@iki.fi>
parents: 8266
diff changeset
194 /* Clear the view. Keep oldest_file_seq and newer log files referenced so we
a6779d086785 mail_transaction_log_view_clear() should keep oldest_file_seq and newer referenced.
Timo Sirainen <tss@iki.fi>
parents: 8266
diff changeset
195 don't get desynced. */
6458
cca479cb3ef0 Keep transaction logs referenced while we know we need them. This fixes
Timo Sirainen <tss@iki.fi>
parents: 6411
diff changeset
196 void mail_transaction_log_view_clear(struct mail_transaction_log_view *view,
cca479cb3ef0 Keep transaction logs referenced while we know we need them. This fixes
Timo Sirainen <tss@iki.fi>
parents: 6411
diff changeset
197 uint32_t oldest_file_seq);
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 /* Read next transaction record from current position. The position is updated.
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
200 Returns -1 if error, 0 if we're at end of the view, 1 if ok. */
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
201 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
202 const struct mail_transaction_header **hdr_r,
5728
7aab5d99fb45 Removed sync_mask parameter from mail_transaction_log_view_set(). The user
Timo Sirainen <tss@iki.fi>
parents: 5714
diff changeset
203 const void **data_r);
7812
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7573
diff changeset
204 /* Mark the current view's position to the record returned previously with
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7573
diff changeset
205 _log_view_next(). */
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7573
diff changeset
206 void mail_transaction_log_view_mark(struct mail_transaction_log_view *view);
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7573
diff changeset
207 /* Seek to previously marked position. */
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7573
diff changeset
208 void mail_transaction_log_view_rewind(struct mail_transaction_log_view *view);
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
209
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
210 /* Returns the position of the record returned previously with
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
211 mail_transaction_log_view_next() */
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
212 void
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
213 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
214 uint32_t *file_seq_r,
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
215 uoff_t *file_offset_r);
7812
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7573
diff changeset
216 /* Return the modseq of the change returned previously with _view_next(). */
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7573
diff changeset
217 uint64_t
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7573
diff changeset
218 mail_transaction_log_view_get_prev_modseq(struct mail_transaction_log_view *view);
5656
1273ce0585b3 Added mail_transaction_log_view_is_last()
Timo Sirainen <tss@iki.fi>
parents: 5278
diff changeset
219 /* Returns TRUE if we're at the end of the view window. */
1273ce0585b3 Added mail_transaction_log_view_is_last()
Timo Sirainen <tss@iki.fi>
parents: 5278
diff changeset
220 bool mail_transaction_log_view_is_last(struct mail_transaction_log_view *view);
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
221
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
222 /* Marks the log file in current position to be corrupted. */
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
223 void
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
224 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
225 const char *fmt, ...)
6411
6a64e64fa3a3 Renamed __attr_*__ to ATTR_*. Renamed __attrs_used__ to ATTRS_DEFINED.
Timo Sirainen <tss@iki.fi>
parents: 6410
diff changeset
226 ATTR_FORMAT(2, 3);
3863
55df57c028d4 Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents: 3833
diff changeset
227 bool
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
228 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
229
1942
2b114aa7eeec handle losing index file
Timo Sirainen <tss@iki.fi>
parents: 1941
diff changeset
230 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
231
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
232 /* Write data to transaction log. This is atomic operation. Sequences in
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
233 updates[] and expunges[] are relative to given view, they're modified
2009
2e77ee652e2e When committing with no changes, don't try to sync them later.
Timo Sirainen <tss@iki.fi>
parents: 1976
diff changeset
234 to real ones. If nothing is written, log_file_seq_r and log_file_offset_r
2e77ee652e2e When committing with no changes, don't try to sync them later.
Timo Sirainen <tss@iki.fi>
parents: 1976
diff changeset
235 will be set to 0. */
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
236 int mail_transaction_log_append(struct mail_index_transaction *t,
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
237 uint32_t *log_file_seq_r,
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
238 uoff_t *log_file_offset_r);
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
239
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
240 /* Lock transaction log for index synchronization. Log cannot be read or
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
241 written to while it's locked. Returns end offset. */
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
242 int mail_transaction_log_sync_lock(struct mail_transaction_log *log,
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
243 uint32_t *file_seq_r, uoff_t *file_offset_r);
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
244 void mail_transaction_log_sync_unlock(struct mail_transaction_log *log);
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
245 /* Returns the current head. Works only when log is locked. */
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
246 void mail_transaction_log_get_head(struct mail_transaction_log *log,
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
247 uint32_t *file_seq_r, uoff_t *file_offset_r);
3832
76f4be7ae499 Handle missing/broken transaction logs better. Handle broken sync position
Timo Sirainen <tss@iki.fi>
parents: 3180
diff changeset
248 /* Returns TRUE if given seq/offset is current head log's rotate point. */
3863
55df57c028d4 Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents: 3833
diff changeset
249 bool mail_transaction_log_is_head_prev(struct mail_transaction_log *log,
55df57c028d4 Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents: 3833
diff changeset
250 uint32_t file_seq, uoff_t file_offset);
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
251
5714
dcf5dbb6a76a mail_transaction_log_move_to_memory() can't fail anymore. Moved the code to
Timo Sirainen <tss@iki.fi>
parents: 5689
diff changeset
252 /* Move currently opened log head file to memory (called by
5689
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5656
diff changeset
253 mail_index_move_to_memory()) */
5714
dcf5dbb6a76a mail_transaction_log_move_to_memory() can't fail anymore. Moved the code to
Timo Sirainen <tss@iki.fi>
parents: 5689
diff changeset
254 void mail_transaction_log_move_to_memory(struct mail_transaction_log *log);
5689
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5656
diff changeset
255
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
256 #endif