Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/lib-index/mail-transaction-log.h @ 2410:c7c886199f28 HEAD
Small cleanups.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 31 Jul 2004 07:35:06 +0300 |
parents | fed6d07bd8ee |
children | 5752e5ac88f0 |
rev | line source |
---|---|
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
1 #ifndef __MAIL_TRANSACTION_LOG_H |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
2 #define __MAIL_TRANSACTION_LOG_H |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
3 |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
4 #define MAIL_TRANSACTION_LOG_PREFIX ".log" |
1940 | 5 #define MAIL_TRANSACTION_LOG_ROTATE_SIZE (1024*128) |
1976
4e0269adb24a
Don't rotate transaction log too often
Timo Sirainen <tss@iki.fi>
parents:
1958
diff
changeset
|
6 #define MAIL_TRANSACTION_LOG_ROTATE_MIN_TIME (60*5) |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
7 |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
8 struct mail_transaction_log_header { |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
9 uint32_t indexid; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
10 uint32_t file_seq; |
1940 | 11 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
|
12 uint32_t prev_file_offset; |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
13 }; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
14 |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
15 enum mail_transaction_type { |
2115
f720b3f15333
Modifying extra_records should work now.
Timo Sirainen <tss@iki.fi>
parents:
2074
diff
changeset
|
16 MAIL_TRANSACTION_EXPUNGE = 0x00000001, |
f720b3f15333
Modifying extra_records should work now.
Timo Sirainen <tss@iki.fi>
parents:
2074
diff
changeset
|
17 MAIL_TRANSACTION_APPEND = 0x00000002, |
f720b3f15333
Modifying extra_records should work now.
Timo Sirainen <tss@iki.fi>
parents:
2074
diff
changeset
|
18 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
|
19 MAIL_TRANSACTION_CACHE_RESET = 0x00000008, |
7bdef5ea4591
Several fixes and cleanups to cache file code, still badly broken
Timo Sirainen <tss@iki.fi>
parents:
2115
diff
changeset
|
20 MAIL_TRANSACTION_CACHE_UPDATE = 0x00000010, |
7bdef5ea4591
Several fixes and cleanups to cache file code, still badly broken
Timo Sirainen <tss@iki.fi>
parents:
2115
diff
changeset
|
21 MAIL_TRANSACTION_HEADER_UPDATE = 0x00000020, |
7bdef5ea4591
Several fixes and cleanups to cache file code, still badly broken
Timo Sirainen <tss@iki.fi>
parents:
2115
diff
changeset
|
22 MAIL_TRANSACTION_EXTRA_REC_UPDATE = 0x00000040, |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
23 |
2115
f720b3f15333
Modifying extra_records should work now.
Timo Sirainen <tss@iki.fi>
parents:
2074
diff
changeset
|
24 MAIL_TRANSACTION_TYPE_MASK = 0x0000ffff, |
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 /* 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
|
27 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
|
28 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
|
29 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
|
30 MAIL_TRANSACTION_EXPUNGE_PROT = 0x0000cd90, |
1915
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 /* Mailbox synchronization noticed this change. */ |
2115
f720b3f15333
Modifying extra_records should work now.
Timo Sirainen <tss@iki.fi>
parents:
2074
diff
changeset
|
33 MAIL_TRANSACTION_EXTERNAL = 0x10000000 |
1915
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 |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
36 struct mail_transaction_header { |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
37 uint32_t size; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
38 uint32_t type; /* enum mail_transaction_type */ |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
39 }; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
40 |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
41 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
|
42 uint32_t uid1, uid2; |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
43 }; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
44 |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
45 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
|
46 uint32_t uid1, uid2; |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
47 uint8_t add_flags; |
1958 | 48 keywords_mask_t add_keywords; |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
49 uint8_t remove_flags; |
1958 | 50 keywords_mask_t remove_keywords; |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
51 }; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
52 |
2201
7bdef5ea4591
Several fixes and cleanups to cache file code, still badly broken
Timo Sirainen <tss@iki.fi>
parents:
2115
diff
changeset
|
53 struct mail_transaction_cache_reset { |
7bdef5ea4591
Several fixes and cleanups to cache file code, still badly broken
Timo Sirainen <tss@iki.fi>
parents:
2115
diff
changeset
|
54 uint32_t new_file_seq; |
7bdef5ea4591
Several fixes and cleanups to cache file code, still badly broken
Timo Sirainen <tss@iki.fi>
parents:
2115
diff
changeset
|
55 }; |
7bdef5ea4591
Several fixes and cleanups to cache file code, still badly broken
Timo Sirainen <tss@iki.fi>
parents:
2115
diff
changeset
|
56 |
2050
ee1095ccfd23
Index header changes now go through transaction log. Removed the kludgy
Timo Sirainen <tss@iki.fi>
parents:
2033
diff
changeset
|
57 struct mail_transaction_cache_update { |
ee1095ccfd23
Index header changes now go through transaction log. Removed the kludgy
Timo Sirainen <tss@iki.fi>
parents:
2033
diff
changeset
|
58 uint32_t uid; |
ee1095ccfd23
Index header changes now go through transaction log. Removed the kludgy
Timo Sirainen <tss@iki.fi>
parents:
2033
diff
changeset
|
59 uint32_t cache_offset; |
ee1095ccfd23
Index header changes now go through transaction log. Removed the kludgy
Timo Sirainen <tss@iki.fi>
parents:
2033
diff
changeset
|
60 }; |
ee1095ccfd23
Index header changes now go through transaction log. Removed the kludgy
Timo Sirainen <tss@iki.fi>
parents:
2033
diff
changeset
|
61 |
ee1095ccfd23
Index header changes now go through transaction log. Removed the kludgy
Timo Sirainen <tss@iki.fi>
parents:
2033
diff
changeset
|
62 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
|
63 uint16_t offset; |
ee1095ccfd23
Index header changes now go through transaction log. Removed the kludgy
Timo Sirainen <tss@iki.fi>
parents:
2033
diff
changeset
|
64 uint16_t size; |
2410 | 65 /* 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
|
66 }; |
ee1095ccfd23
Index header changes now go through transaction log. Removed the kludgy
Timo Sirainen <tss@iki.fi>
parents:
2033
diff
changeset
|
67 |
2115
f720b3f15333
Modifying extra_records should work now.
Timo Sirainen <tss@iki.fi>
parents:
2074
diff
changeset
|
68 struct mail_transaction_extra_rec_header { |
2410 | 69 uint32_t data_id; |
2115
f720b3f15333
Modifying extra_records should work now.
Timo Sirainen <tss@iki.fi>
parents:
2074
diff
changeset
|
70 }; |
f720b3f15333
Modifying extra_records should work now.
Timo Sirainen <tss@iki.fi>
parents:
2074
diff
changeset
|
71 |
f720b3f15333
Modifying extra_records should work now.
Timo Sirainen <tss@iki.fi>
parents:
2074
diff
changeset
|
72 struct mail_transaction_extra_rec_update { |
f720b3f15333
Modifying extra_records should work now.
Timo Sirainen <tss@iki.fi>
parents:
2074
diff
changeset
|
73 uint32_t uid; |
2410 | 74 /* unsigned char data[]; */ |
2115
f720b3f15333
Modifying extra_records should work now.
Timo Sirainen <tss@iki.fi>
parents:
2074
diff
changeset
|
75 }; |
f720b3f15333
Modifying extra_records should work now.
Timo Sirainen <tss@iki.fi>
parents:
2074
diff
changeset
|
76 |
2240
51719889ffcf
Record size is allowed to change between index files. This will allow adding
Timo Sirainen <tss@iki.fi>
parents:
2201
diff
changeset
|
77 struct mail_transaction_append_header { |
51719889ffcf
Record size is allowed to change between index files. This will allow adding
Timo Sirainen <tss@iki.fi>
parents:
2201
diff
changeset
|
78 uint32_t record_size; |
51719889ffcf
Record size is allowed to change between index files. This will allow adding
Timo Sirainen <tss@iki.fi>
parents:
2201
diff
changeset
|
79 }; |
51719889ffcf
Record size is allowed to change between index files. This will allow adding
Timo Sirainen <tss@iki.fi>
parents:
2201
diff
changeset
|
80 |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
81 struct mail_transaction_log * |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
82 mail_transaction_log_open_or_create(struct mail_index *index); |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
83 void mail_transaction_log_close(struct mail_transaction_log *log); |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
84 |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
85 struct mail_transaction_log_view * |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
86 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
|
87 void mail_transaction_log_view_close(struct mail_transaction_log_view *view); |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
88 |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
89 /* Set view boundaries. Returns -1 if error, 0 if ok. */ |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
90 int |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
91 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
|
92 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
|
93 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
|
94 enum mail_transaction_type type_mask); |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
95 |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
96 /* 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
|
97 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
|
98 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
|
99 const struct mail_transaction_header **hdr_r, |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
100 const void **data_r, int *skipped_r); |
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 /* 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
|
103 mail_transaction_log_view_next() */ |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
104 void |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
105 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
|
106 uint32_t *file_seq_r, |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
107 uoff_t *file_offset_r); |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
108 |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
109 /* 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
|
110 void |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
111 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
|
112 const char *fmt, ...) |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
113 __attr_format__(2, 3); |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
114 int |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
115 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
|
116 |
1942 | 117 void mail_transaction_log_views_close(struct mail_transaction_log *log); |
118 | |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
119 /* 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
|
120 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
|
121 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
|
122 will be set to 0. */ |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
123 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
|
124 uint32_t *log_file_seq_r, |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
125 uoff_t *log_file_offset_r); |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
126 |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
127 /* 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
|
128 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
|
129 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
|
130 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
|
131 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
|
132 /* 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
|
133 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
|
134 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
|
135 |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
136 #endif |