Mercurial > dovecot > core-2.2
annotate src/lib-index/mail-index.c @ 9420:c496f137c843 HEAD
index: Handle better errors where a new file's group can't be changed.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 31 May 2009 22:03:25 -0400 |
parents | a9a532d4f00e |
children | 14ed9ca980d1 |
rev | line source |
---|---|
8590
b9faf4db2a9f
Updated copyright notices to include year 2009.
Timo Sirainen <tss@iki.fi>
parents:
8573
diff
changeset
|
1 /* Copyright (c) 2003-2009 Dovecot authors, see the included COPYING file */ |
1915
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" |
5819 | 4 #include "ioloop.h" |
3470
346a494c2feb
Moved array declaration to array-decl.h and include it in lib.h. So array.h
Timo Sirainen <tss@iki.fi>
parents:
3445
diff
changeset
|
5 #include "array.h" |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
6 #include "buffer.h" |
3254
a2943c050571
Keywords are now stored in X-Keywords headers in mbox. Did several related
Timo Sirainen <tss@iki.fi>
parents:
3243
diff
changeset
|
7 #include "hash.h" |
6384
2c8b1d487728
Make sure the extension name doesn't contain control characters. It most
Timo Sirainen <tss@iki.fi>
parents:
6378
diff
changeset
|
8 #include "str-sanitize.h" |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
9 #include "mmap-util.h" |
4071
cd3d26cf124a
Renamed safe-open.* to nfs-workarounds.*, safe_open() to nfs_safe_open() and
Timo Sirainen <tss@iki.fi>
parents:
4067
diff
changeset
|
10 #include "nfs-workarounds.h" |
1917
68938dccbc45
Forced locking to be right with mprotect()ing index file. Support for
Timo Sirainen <tss@iki.fi>
parents:
1915
diff
changeset
|
11 #include "read-full.h" |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
12 #include "write-full.h" |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
13 #include "mail-index-private.h" |
5272
82b4a055e109
mmap_disable=yes crashes with recent changes.
Timo Sirainen <tss@iki.fi>
parents:
5247
diff
changeset
|
14 #include "mail-index-view-private.h" |
2885
1880f191278a
Avoid re-reading index file with mmap_disabled=yes. Instead sync it by
Timo Sirainen <tss@iki.fi>
parents:
2884
diff
changeset
|
15 #include "mail-index-sync-private.h" |
7620 | 16 #include "mail-index-modseq.h" |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
17 #include "mail-transaction-log.h" |
2200
97bb7b127617
Beginnings of getting cache file working again. Easy to break currently, but
Timo Sirainen <tss@iki.fi>
parents:
2193
diff
changeset
|
18 #include "mail-cache.h" |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
19 |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
20 #include <stdio.h> |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
21 #include <stddef.h> |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
22 #include <time.h> |
1917
68938dccbc45
Forced locking to be right with mprotect()ing index file. Support for
Timo Sirainen <tss@iki.fi>
parents:
1915
diff
changeset
|
23 #include <sys/stat.h> |
68938dccbc45
Forced locking to be right with mprotect()ing index file. Support for
Timo Sirainen <tss@iki.fi>
parents:
1915
diff
changeset
|
24 |
5453
a0a1432bb4e8
Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents:
5430
diff
changeset
|
25 struct mail_index_module_register mail_index_module_register = { 0 }; |
4453
85fcdb478608
Beginnings of joining mail-storage API more closely to mail-index, so that
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4451
diff
changeset
|
26 |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
27 struct mail_index *mail_index_alloc(const char *dir, const char *prefix) |
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 struct mail_index *index; |
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 index = i_new(struct mail_index, 1); |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
32 index->dir = i_strdup(dir); |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
33 index->prefix = i_strdup(prefix); |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
34 index->fd = -1; |
2116 | 35 |
5028 | 36 index->extension_pool = |
37 pool_alloconly_create(MEMPOOL_GROWING"index extension", 1024); | |
4596
bf4e98a0de3f
Replaced ARRAY_CREATE() macro with [ipt]_array_init() macros. The macro
Timo Sirainen <tss@iki.fi>
parents:
4594
diff
changeset
|
38 p_array_init(&index->extensions, index->extension_pool, 5); |
bf4e98a0de3f
Replaced ARRAY_CREATE() macro with [ipt]_array_init() macros. The macro
Timo Sirainen <tss@iki.fi>
parents:
4594
diff
changeset
|
39 i_array_init(&index->sync_lost_handlers, 4); |
5453
a0a1432bb4e8
Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents:
5430
diff
changeset
|
40 i_array_init(&index->module_contexts, |
a0a1432bb4e8
Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents:
5430
diff
changeset
|
41 I_MIN(5, mail_index_module_register.id)); |
4453
85fcdb478608
Beginnings of joining mail-storage API more closely to mail-index, so that
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4451
diff
changeset
|
42 |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
43 index->mode = 0600; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
44 index->gid = (gid_t)-1; |
3016
61c8d205d887
Initial support for keywords. Syncing to mbox/maildir doesn't work yet.
Timo Sirainen <tss@iki.fi>
parents:
2956
diff
changeset
|
45 |
61c8d205d887
Initial support for keywords. Syncing to mbox/maildir doesn't work yet.
Timo Sirainen <tss@iki.fi>
parents:
2956
diff
changeset
|
46 index->keywords_ext_id = |
8547
545cb188f7ab
Replaced literal "keywords" strings with a macro.
Timo Sirainen <tss@iki.fi>
parents:
8146
diff
changeset
|
47 mail_index_ext_register(index, MAIL_INDEX_EXT_KEYWORDS, |
545cb188f7ab
Replaced literal "keywords" strings with a macro.
Timo Sirainen <tss@iki.fi>
parents:
8146
diff
changeset
|
48 128, 2, 1); |
3086 | 49 index->keywords_pool = pool_alloconly_create("keywords", 512); |
4596
bf4e98a0de3f
Replaced ARRAY_CREATE() macro with [ipt]_array_init() macros. The macro
Timo Sirainen <tss@iki.fi>
parents:
4594
diff
changeset
|
50 i_array_init(&index->keywords, 16); |
3254
a2943c050571
Keywords are now stored in X-Keywords headers in mbox. Did several related
Timo Sirainen <tss@iki.fi>
parents:
3243
diff
changeset
|
51 index->keywords_hash = |
8573
f9166a09423a
Renamed hash_*() to hash_table_*() to avoid conflicts with OSX's strhash.h
Timo Sirainen <tss@iki.fi>
parents:
8572
diff
changeset
|
52 hash_table_create(default_pool, index->keywords_pool, 0, |
f9166a09423a
Renamed hash_*() to hash_table_*() to avoid conflicts with OSX's strhash.h
Timo Sirainen <tss@iki.fi>
parents:
8572
diff
changeset
|
53 strcase_hash, (hash_cmp_callback_t *)strcasecmp); |
5689
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
54 index->log = mail_transaction_log_alloc(index); |
7620 | 55 mail_index_modseq_init(index); |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
56 return index; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
57 } |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
58 |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
59 void mail_index_free(struct mail_index **_index) |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
60 { |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
61 struct mail_index *index = *_index; |
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
62 |
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
63 *_index = NULL; |
1967 | 64 mail_index_close(index); |
3254
a2943c050571
Keywords are now stored in X-Keywords headers in mbox. Did several related
Timo Sirainen <tss@iki.fi>
parents:
3243
diff
changeset
|
65 |
5689
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
66 mail_transaction_log_free(&index->log); |
8573
f9166a09423a
Renamed hash_*() to hash_table_*() to avoid conflicts with OSX's strhash.h
Timo Sirainen <tss@iki.fi>
parents:
8572
diff
changeset
|
67 hash_table_destroy(&index->keywords_hash); |
6428
7cad076906eb
pool_unref() now takes ** pointer.
Timo Sirainen <tss@iki.fi>
parents:
6417
diff
changeset
|
68 pool_unref(&index->extension_pool); |
7cad076906eb
pool_unref() now takes ** pointer.
Timo Sirainen <tss@iki.fi>
parents:
6417
diff
changeset
|
69 pool_unref(&index->keywords_pool); |
1967 | 70 |
3191
0df3f5d71958
Changed many buffers to arrays. Cleans up the code a lot.
Timo Sirainen <tss@iki.fi>
parents:
3179
diff
changeset
|
71 array_free(&index->sync_lost_handlers); |
3254
a2943c050571
Keywords are now stored in X-Keywords headers in mbox. Did several related
Timo Sirainen <tss@iki.fi>
parents:
3243
diff
changeset
|
72 array_free(&index->keywords); |
5453
a0a1432bb4e8
Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents:
5430
diff
changeset
|
73 array_free(&index->module_contexts); |
2853
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2825
diff
changeset
|
74 |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
75 i_free(index->error); |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
76 i_free(index->dir); |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
77 i_free(index->prefix); |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
78 i_free(index); |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
79 } |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
80 |
6736
3e189cbb7e7a
fsync transaction commits only if the transaction contains change types
Timo Sirainen <tss@iki.fi>
parents:
6686
diff
changeset
|
81 void mail_index_set_fsync_types(struct mail_index *index, |
3e189cbb7e7a
fsync transaction commits only if the transaction contains change types
Timo Sirainen <tss@iki.fi>
parents:
6686
diff
changeset
|
82 enum mail_index_sync_type fsync_mask) |
3e189cbb7e7a
fsync transaction commits only if the transaction contains change types
Timo Sirainen <tss@iki.fi>
parents:
6686
diff
changeset
|
83 { |
3e189cbb7e7a
fsync transaction commits only if the transaction contains change types
Timo Sirainen <tss@iki.fi>
parents:
6686
diff
changeset
|
84 index->fsync_mask = fsync_mask; |
3e189cbb7e7a
fsync transaction commits only if the transaction contains change types
Timo Sirainen <tss@iki.fi>
parents:
6686
diff
changeset
|
85 } |
3e189cbb7e7a
fsync transaction commits only if the transaction contains change types
Timo Sirainen <tss@iki.fi>
parents:
6686
diff
changeset
|
86 |
2650
9b78674428f5
Get index file mode and GID from dovecot-shared file.
Timo Sirainen <tss@iki.fi>
parents:
2618
diff
changeset
|
87 void mail_index_set_permissions(struct mail_index *index, |
9b78674428f5
Get index file mode and GID from dovecot-shared file.
Timo Sirainen <tss@iki.fi>
parents:
2618
diff
changeset
|
88 mode_t mode, gid_t gid) |
9b78674428f5
Get index file mode and GID from dovecot-shared file.
Timo Sirainen <tss@iki.fi>
parents:
2618
diff
changeset
|
89 { |
9b78674428f5
Get index file mode and GID from dovecot-shared file.
Timo Sirainen <tss@iki.fi>
parents:
2618
diff
changeset
|
90 index->mode = mode & 0666; |
9b78674428f5
Get index file mode and GID from dovecot-shared file.
Timo Sirainen <tss@iki.fi>
parents:
2618
diff
changeset
|
91 index->gid = gid; |
9b78674428f5
Get index file mode and GID from dovecot-shared file.
Timo Sirainen <tss@iki.fi>
parents:
2618
diff
changeset
|
92 } |
9b78674428f5
Get index file mode and GID from dovecot-shared file.
Timo Sirainen <tss@iki.fi>
parents:
2618
diff
changeset
|
93 |
2671
3b70ddb51771
Renamed "extra record info" and variations of it to "extension" or "ext" in
Timo Sirainen <tss@iki.fi>
parents:
2660
diff
changeset
|
94 uint32_t mail_index_ext_register(struct mail_index *index, const char *name, |
2683
d41c42a7bf1e
Index extensions can now specify record alignment, and it's possible to
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
95 uint32_t default_hdr_size, |
d41c42a7bf1e
Index extensions can now specify record alignment, and it's possible to
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
96 uint16_t default_record_size, |
d41c42a7bf1e
Index extensions can now specify record alignment, and it's possible to
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
97 uint16_t default_record_align) |
2114
4aedcb4c51cb
Added support for per-index sized mail_index_record.
Timo Sirainen <tss@iki.fi>
parents:
2095
diff
changeset
|
98 { |
3816
575c79a0aabc
Cleanup: Created mail_index_registered_ext which is used for
Timo Sirainen <tss@iki.fi>
parents:
3582
diff
changeset
|
99 struct mail_index_registered_ext rext; |
6679 | 100 uint32_t ext_id; |
2115
f720b3f15333
Modifying extra_records should work now.
Timo Sirainen <tss@iki.fi>
parents:
2114
diff
changeset
|
101 |
6871
f7ec019fd3f6
mail_index_ext_register(): Panic if parameters aren't correct.
Timo Sirainen <tss@iki.fi>
parents:
6857
diff
changeset
|
102 if (*name == '\0' || strcmp(name, str_sanitize(name, -1)) != 0) |
6384
2c8b1d487728
Make sure the extension name doesn't contain control characters. It most
Timo Sirainen <tss@iki.fi>
parents:
6378
diff
changeset
|
103 i_panic("mail_index_ext_register(%s): Invalid name", name); |
2c8b1d487728
Make sure the extension name doesn't contain control characters. It most
Timo Sirainen <tss@iki.fi>
parents:
6378
diff
changeset
|
104 |
7361
11eb0bd76299
mail_index_ext_register(): Allow registering an extension without record or
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
105 if (default_record_size != 0 && default_record_align == 0) { |
6871
f7ec019fd3f6
mail_index_ext_register(): Panic if parameters aren't correct.
Timo Sirainen <tss@iki.fi>
parents:
6857
diff
changeset
|
106 i_panic("mail_index_ext_register(%s): " |
7361
11eb0bd76299
mail_index_ext_register(): Allow registering an extension without record or
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
107 "Invalid record alignment", name); |
6871
f7ec019fd3f6
mail_index_ext_register(): Panic if parameters aren't correct.
Timo Sirainen <tss@iki.fi>
parents:
6857
diff
changeset
|
108 } |
f7ec019fd3f6
mail_index_ext_register(): Panic if parameters aren't correct.
Timo Sirainen <tss@iki.fi>
parents:
6857
diff
changeset
|
109 |
6679 | 110 if (mail_index_ext_lookup(index, name, &ext_id)) |
111 return ext_id; | |
2116 | 112 |
3816
575c79a0aabc
Cleanup: Created mail_index_registered_ext which is used for
Timo Sirainen <tss@iki.fi>
parents:
3582
diff
changeset
|
113 memset(&rext, 0, sizeof(rext)); |
575c79a0aabc
Cleanup: Created mail_index_registered_ext which is used for
Timo Sirainen <tss@iki.fi>
parents:
3582
diff
changeset
|
114 rext.name = p_strdup(index->extension_pool, name); |
6679 | 115 rext.index_idx = array_count(&index->extensions); |
3816
575c79a0aabc
Cleanup: Created mail_index_registered_ext which is used for
Timo Sirainen <tss@iki.fi>
parents:
3582
diff
changeset
|
116 rext.hdr_size = default_hdr_size; |
575c79a0aabc
Cleanup: Created mail_index_registered_ext which is used for
Timo Sirainen <tss@iki.fi>
parents:
3582
diff
changeset
|
117 rext.record_size = default_record_size; |
575c79a0aabc
Cleanup: Created mail_index_registered_ext which is used for
Timo Sirainen <tss@iki.fi>
parents:
3582
diff
changeset
|
118 rext.record_align = default_record_align; |
2563
5752e5ac88f0
Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents:
2553
diff
changeset
|
119 |
3816
575c79a0aabc
Cleanup: Created mail_index_registered_ext which is used for
Timo Sirainen <tss@iki.fi>
parents:
3582
diff
changeset
|
120 array_append(&index->extensions, &rext, 1); |
6679 | 121 return rext.index_idx; |
122 } | |
123 | |
124 bool mail_index_ext_lookup(struct mail_index *index, const char *name, | |
125 uint32_t *ext_id_r) | |
126 { | |
127 const struct mail_index_registered_ext *extensions; | |
128 unsigned int i, count; | |
129 | |
130 extensions = array_get(&index->extensions, &count); | |
131 for (i = 0; i < count; i++) { | |
132 if (strcmp(extensions[i].name, name) == 0) { | |
133 *ext_id_r = i; | |
134 return TRUE; | |
135 } | |
136 } | |
137 | |
138 *ext_id_r = (uint32_t)-1; | |
139 return FALSE; | |
2563
5752e5ac88f0
Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents:
2553
diff
changeset
|
140 } |
5752e5ac88f0
Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents:
2553
diff
changeset
|
141 |
2853
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2825
diff
changeset
|
142 void mail_index_register_expunge_handler(struct mail_index *index, |
4903
204d7edc7cdc
Added context parameter type safety checks for most callback APIs.
Timo Sirainen <tss@iki.fi>
parents:
4876
diff
changeset
|
143 uint32_t ext_id, bool call_always, |
4490
56d17f2e1d66
Added support for calling expunge handler for an extension even if the
Timo Sirainen <tss@iki.fi>
parents:
4453
diff
changeset
|
144 mail_index_expunge_handler_t *cb, |
4903
204d7edc7cdc
Added context parameter type safety checks for most callback APIs.
Timo Sirainen <tss@iki.fi>
parents:
4876
diff
changeset
|
145 void *context) |
2853
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2825
diff
changeset
|
146 { |
3817
dc560ef2654b
Moved expunge handlers to mail_index_registered_ext.
Timo Sirainen <tss@iki.fi>
parents:
3816
diff
changeset
|
147 struct mail_index_registered_ext *rext; |
3224
f6e0d1826645
Added sync/sync_lost/expunge handler unregistering, and also do that. Fixes
Timo Sirainen <tss@iki.fi>
parents:
3222
diff
changeset
|
148 |
4451
1a35d53c18fc
Array API redesigned to work using unions. It now provides type safety
Timo Sirainen <tss@iki.fi>
parents:
4396
diff
changeset
|
149 rext = array_idx_modifiable(&index->extensions, ext_id); |
4616 | 150 i_assert(rext->expunge_handler == NULL || rext->expunge_handler == cb); |
3224
f6e0d1826645
Added sync/sync_lost/expunge handler unregistering, and also do that. Fixes
Timo Sirainen <tss@iki.fi>
parents:
3222
diff
changeset
|
151 |
3817
dc560ef2654b
Moved expunge handlers to mail_index_registered_ext.
Timo Sirainen <tss@iki.fi>
parents:
3816
diff
changeset
|
152 rext->expunge_handler = cb; |
4490
56d17f2e1d66
Added support for calling expunge handler for an extension even if the
Timo Sirainen <tss@iki.fi>
parents:
4453
diff
changeset
|
153 rext->expunge_context = context; |
56d17f2e1d66
Added support for calling expunge handler for an extension even if the
Timo Sirainen <tss@iki.fi>
parents:
4453
diff
changeset
|
154 rext->expunge_handler_call_always = call_always; |
3224
f6e0d1826645
Added sync/sync_lost/expunge handler unregistering, and also do that. Fixes
Timo Sirainen <tss@iki.fi>
parents:
3222
diff
changeset
|
155 } |
f6e0d1826645
Added sync/sync_lost/expunge handler unregistering, and also do that. Fixes
Timo Sirainen <tss@iki.fi>
parents:
3222
diff
changeset
|
156 |
f6e0d1826645
Added sync/sync_lost/expunge handler unregistering, and also do that. Fixes
Timo Sirainen <tss@iki.fi>
parents:
3222
diff
changeset
|
157 void mail_index_unregister_expunge_handler(struct mail_index *index, |
f6e0d1826645
Added sync/sync_lost/expunge handler unregistering, and also do that. Fixes
Timo Sirainen <tss@iki.fi>
parents:
3222
diff
changeset
|
158 uint32_t ext_id) |
f6e0d1826645
Added sync/sync_lost/expunge handler unregistering, and also do that. Fixes
Timo Sirainen <tss@iki.fi>
parents:
3222
diff
changeset
|
159 { |
3817
dc560ef2654b
Moved expunge handlers to mail_index_registered_ext.
Timo Sirainen <tss@iki.fi>
parents:
3816
diff
changeset
|
160 struct mail_index_registered_ext *rext; |
3224
f6e0d1826645
Added sync/sync_lost/expunge handler unregistering, and also do that. Fixes
Timo Sirainen <tss@iki.fi>
parents:
3222
diff
changeset
|
161 |
4451
1a35d53c18fc
Array API redesigned to work using unions. It now provides type safety
Timo Sirainen <tss@iki.fi>
parents:
4396
diff
changeset
|
162 rext = array_idx_modifiable(&index->extensions, ext_id); |
3817
dc560ef2654b
Moved expunge handlers to mail_index_registered_ext.
Timo Sirainen <tss@iki.fi>
parents:
3816
diff
changeset
|
163 i_assert(rext->expunge_handler != NULL); |
3224
f6e0d1826645
Added sync/sync_lost/expunge handler unregistering, and also do that. Fixes
Timo Sirainen <tss@iki.fi>
parents:
3222
diff
changeset
|
164 |
3817
dc560ef2654b
Moved expunge handlers to mail_index_registered_ext.
Timo Sirainen <tss@iki.fi>
parents:
3816
diff
changeset
|
165 rext->expunge_handler = NULL; |
2853
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2825
diff
changeset
|
166 } |
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2825
diff
changeset
|
167 |
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2825
diff
changeset
|
168 void mail_index_register_sync_handler(struct mail_index *index, uint32_t ext_id, |
2869
d2daf90c79f1
Cache invalidating needed to hook into view syncing as well.
Timo Sirainen <tss@iki.fi>
parents:
2857
diff
changeset
|
169 mail_index_sync_handler_t *cb, |
d2daf90c79f1
Cache invalidating needed to hook into view syncing as well.
Timo Sirainen <tss@iki.fi>
parents:
2857
diff
changeset
|
170 enum mail_index_sync_handler_type type) |
2853
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2825
diff
changeset
|
171 { |
3816
575c79a0aabc
Cleanup: Created mail_index_registered_ext which is used for
Timo Sirainen <tss@iki.fi>
parents:
3582
diff
changeset
|
172 struct mail_index_registered_ext *rext; |
2869
d2daf90c79f1
Cache invalidating needed to hook into view syncing as well.
Timo Sirainen <tss@iki.fi>
parents:
2857
diff
changeset
|
173 |
4451
1a35d53c18fc
Array API redesigned to work using unions. It now provides type safety
Timo Sirainen <tss@iki.fi>
parents:
4396
diff
changeset
|
174 rext = array_idx_modifiable(&index->extensions, ext_id); |
3816
575c79a0aabc
Cleanup: Created mail_index_registered_ext which is used for
Timo Sirainen <tss@iki.fi>
parents:
3582
diff
changeset
|
175 i_assert(rext->sync_handler.callback == NULL); |
3224
f6e0d1826645
Added sync/sync_lost/expunge handler unregistering, and also do that. Fixes
Timo Sirainen <tss@iki.fi>
parents:
3222
diff
changeset
|
176 |
3816
575c79a0aabc
Cleanup: Created mail_index_registered_ext which is used for
Timo Sirainen <tss@iki.fi>
parents:
3582
diff
changeset
|
177 rext->sync_handler.callback = cb; |
575c79a0aabc
Cleanup: Created mail_index_registered_ext which is used for
Timo Sirainen <tss@iki.fi>
parents:
3582
diff
changeset
|
178 rext->sync_handler.type = type; |
2853
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2825
diff
changeset
|
179 } |
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2825
diff
changeset
|
180 |
3224
f6e0d1826645
Added sync/sync_lost/expunge handler unregistering, and also do that. Fixes
Timo Sirainen <tss@iki.fi>
parents:
3222
diff
changeset
|
181 void mail_index_unregister_sync_handler(struct mail_index *index, |
f6e0d1826645
Added sync/sync_lost/expunge handler unregistering, and also do that. Fixes
Timo Sirainen <tss@iki.fi>
parents:
3222
diff
changeset
|
182 uint32_t ext_id) |
f6e0d1826645
Added sync/sync_lost/expunge handler unregistering, and also do that. Fixes
Timo Sirainen <tss@iki.fi>
parents:
3222
diff
changeset
|
183 { |
3816
575c79a0aabc
Cleanup: Created mail_index_registered_ext which is used for
Timo Sirainen <tss@iki.fi>
parents:
3582
diff
changeset
|
184 struct mail_index_registered_ext *rext; |
3224
f6e0d1826645
Added sync/sync_lost/expunge handler unregistering, and also do that. Fixes
Timo Sirainen <tss@iki.fi>
parents:
3222
diff
changeset
|
185 |
4451
1a35d53c18fc
Array API redesigned to work using unions. It now provides type safety
Timo Sirainen <tss@iki.fi>
parents:
4396
diff
changeset
|
186 rext = array_idx_modifiable(&index->extensions, ext_id); |
3816
575c79a0aabc
Cleanup: Created mail_index_registered_ext which is used for
Timo Sirainen <tss@iki.fi>
parents:
3582
diff
changeset
|
187 i_assert(rext->sync_handler.callback != NULL); |
3224
f6e0d1826645
Added sync/sync_lost/expunge handler unregistering, and also do that. Fixes
Timo Sirainen <tss@iki.fi>
parents:
3222
diff
changeset
|
188 |
3816
575c79a0aabc
Cleanup: Created mail_index_registered_ext which is used for
Timo Sirainen <tss@iki.fi>
parents:
3582
diff
changeset
|
189 rext->sync_handler.callback = NULL; |
575c79a0aabc
Cleanup: Created mail_index_registered_ext which is used for
Timo Sirainen <tss@iki.fi>
parents:
3582
diff
changeset
|
190 rext->sync_handler.type = 0; |
3224
f6e0d1826645
Added sync/sync_lost/expunge handler unregistering, and also do that. Fixes
Timo Sirainen <tss@iki.fi>
parents:
3222
diff
changeset
|
191 } |
f6e0d1826645
Added sync/sync_lost/expunge handler unregistering, and also do that. Fixes
Timo Sirainen <tss@iki.fi>
parents:
3222
diff
changeset
|
192 |
2934
c3ae75597952
Added "sync lost" handlers which are called with mmap_disable=yes when index
Timo Sirainen <tss@iki.fi>
parents:
2926
diff
changeset
|
193 void mail_index_register_sync_lost_handler(struct mail_index *index, |
c3ae75597952
Added "sync lost" handlers which are called with mmap_disable=yes when index
Timo Sirainen <tss@iki.fi>
parents:
2926
diff
changeset
|
194 mail_index_sync_lost_handler_t *cb) |
c3ae75597952
Added "sync lost" handlers which are called with mmap_disable=yes when index
Timo Sirainen <tss@iki.fi>
parents:
2926
diff
changeset
|
195 { |
3191
0df3f5d71958
Changed many buffers to arrays. Cleans up the code a lot.
Timo Sirainen <tss@iki.fi>
parents:
3179
diff
changeset
|
196 array_append(&index->sync_lost_handlers, &cb, 1); |
2934
c3ae75597952
Added "sync lost" handlers which are called with mmap_disable=yes when index
Timo Sirainen <tss@iki.fi>
parents:
2926
diff
changeset
|
197 } |
c3ae75597952
Added "sync lost" handlers which are called with mmap_disable=yes when index
Timo Sirainen <tss@iki.fi>
parents:
2926
diff
changeset
|
198 |
3224
f6e0d1826645
Added sync/sync_lost/expunge handler unregistering, and also do that. Fixes
Timo Sirainen <tss@iki.fi>
parents:
3222
diff
changeset
|
199 void mail_index_unregister_sync_lost_handler(struct mail_index *index, |
f6e0d1826645
Added sync/sync_lost/expunge handler unregistering, and also do that. Fixes
Timo Sirainen <tss@iki.fi>
parents:
3222
diff
changeset
|
200 mail_index_sync_lost_handler_t *cb) |
f6e0d1826645
Added sync/sync_lost/expunge handler unregistering, and also do that. Fixes
Timo Sirainen <tss@iki.fi>
parents:
3222
diff
changeset
|
201 { |
f6e0d1826645
Added sync/sync_lost/expunge handler unregistering, and also do that. Fixes
Timo Sirainen <tss@iki.fi>
parents:
3222
diff
changeset
|
202 mail_index_sync_lost_handler_t *const *handlers; |
f6e0d1826645
Added sync/sync_lost/expunge handler unregistering, and also do that. Fixes
Timo Sirainen <tss@iki.fi>
parents:
3222
diff
changeset
|
203 unsigned int i, count; |
f6e0d1826645
Added sync/sync_lost/expunge handler unregistering, and also do that. Fixes
Timo Sirainen <tss@iki.fi>
parents:
3222
diff
changeset
|
204 |
f6e0d1826645
Added sync/sync_lost/expunge handler unregistering, and also do that. Fixes
Timo Sirainen <tss@iki.fi>
parents:
3222
diff
changeset
|
205 handlers = array_get(&index->sync_lost_handlers, &count); |
f6e0d1826645
Added sync/sync_lost/expunge handler unregistering, and also do that. Fixes
Timo Sirainen <tss@iki.fi>
parents:
3222
diff
changeset
|
206 for (i = 0; i < count; i++) { |
f6e0d1826645
Added sync/sync_lost/expunge handler unregistering, and also do that. Fixes
Timo Sirainen <tss@iki.fi>
parents:
3222
diff
changeset
|
207 if (handlers[i] == cb) { |
f6e0d1826645
Added sync/sync_lost/expunge handler unregistering, and also do that. Fixes
Timo Sirainen <tss@iki.fi>
parents:
3222
diff
changeset
|
208 array_delete(&index->sync_lost_handlers, i, 1); |
f6e0d1826645
Added sync/sync_lost/expunge handler unregistering, and also do that. Fixes
Timo Sirainen <tss@iki.fi>
parents:
3222
diff
changeset
|
209 break; |
f6e0d1826645
Added sync/sync_lost/expunge handler unregistering, and also do that. Fixes
Timo Sirainen <tss@iki.fi>
parents:
3222
diff
changeset
|
210 } |
f6e0d1826645
Added sync/sync_lost/expunge handler unregistering, and also do that. Fixes
Timo Sirainen <tss@iki.fi>
parents:
3222
diff
changeset
|
211 } |
f6e0d1826645
Added sync/sync_lost/expunge handler unregistering, and also do that. Fixes
Timo Sirainen <tss@iki.fi>
parents:
3222
diff
changeset
|
212 } |
f6e0d1826645
Added sync/sync_lost/expunge handler unregistering, and also do that. Fixes
Timo Sirainen <tss@iki.fi>
parents:
3222
diff
changeset
|
213 |
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
|
214 bool mail_index_keyword_lookup(struct mail_index *index, |
6335
a1c587d3d633
Removed autocreate parameter from mail_index_keyword_lookup(). Added a new
Timo Sirainen <tss@iki.fi>
parents:
6330
diff
changeset
|
215 const char *keyword, unsigned int *idx_r) |
3254
a2943c050571
Keywords are now stored in X-Keywords headers in mbox. Did several related
Timo Sirainen <tss@iki.fi>
parents:
3243
diff
changeset
|
216 { |
a2943c050571
Keywords are now stored in X-Keywords headers in mbox. Did several related
Timo Sirainen <tss@iki.fi>
parents:
3243
diff
changeset
|
217 void *value; |
a2943c050571
Keywords are now stored in X-Keywords headers in mbox. Did several related
Timo Sirainen <tss@iki.fi>
parents:
3243
diff
changeset
|
218 |
3818
6758c0f3c318
Comment updates and minor cleanups
Timo Sirainen <tss@iki.fi>
parents:
3817
diff
changeset
|
219 /* keywords_hash keeps a name => index mapping of keywords. |
6758c0f3c318
Comment updates and minor cleanups
Timo Sirainen <tss@iki.fi>
parents:
3817
diff
changeset
|
220 Keywords are never removed from it, so the index values are valid |
6758c0f3c318
Comment updates and minor cleanups
Timo Sirainen <tss@iki.fi>
parents:
3817
diff
changeset
|
221 for the lifetime of the mail_index. */ |
8573
f9166a09423a
Renamed hash_*() to hash_table_*() to avoid conflicts with OSX's strhash.h
Timo Sirainen <tss@iki.fi>
parents:
8572
diff
changeset
|
222 if (hash_table_lookup_full(index->keywords_hash, keyword, |
f9166a09423a
Renamed hash_*() to hash_table_*() to avoid conflicts with OSX's strhash.h
Timo Sirainen <tss@iki.fi>
parents:
8572
diff
changeset
|
223 NULL, &value)) { |
3254
a2943c050571
Keywords are now stored in X-Keywords headers in mbox. Did several related
Timo Sirainen <tss@iki.fi>
parents:
3243
diff
changeset
|
224 *idx_r = POINTER_CAST_TO(value, unsigned int); |
a2943c050571
Keywords are now stored in X-Keywords headers in mbox. Did several related
Timo Sirainen <tss@iki.fi>
parents:
3243
diff
changeset
|
225 return TRUE; |
a2943c050571
Keywords are now stored in X-Keywords headers in mbox. Did several related
Timo Sirainen <tss@iki.fi>
parents:
3243
diff
changeset
|
226 } |
a2943c050571
Keywords are now stored in X-Keywords headers in mbox. Did several related
Timo Sirainen <tss@iki.fi>
parents:
3243
diff
changeset
|
227 |
6335
a1c587d3d633
Removed autocreate parameter from mail_index_keyword_lookup(). Added a new
Timo Sirainen <tss@iki.fi>
parents:
6330
diff
changeset
|
228 *idx_r = (unsigned int)-1; |
a1c587d3d633
Removed autocreate parameter from mail_index_keyword_lookup(). Added a new
Timo Sirainen <tss@iki.fi>
parents:
6330
diff
changeset
|
229 return FALSE; |
a1c587d3d633
Removed autocreate parameter from mail_index_keyword_lookup(). Added a new
Timo Sirainen <tss@iki.fi>
parents:
6330
diff
changeset
|
230 } |
a1c587d3d633
Removed autocreate parameter from mail_index_keyword_lookup(). Added a new
Timo Sirainen <tss@iki.fi>
parents:
6330
diff
changeset
|
231 |
a1c587d3d633
Removed autocreate parameter from mail_index_keyword_lookup(). Added a new
Timo Sirainen <tss@iki.fi>
parents:
6330
diff
changeset
|
232 void mail_index_keyword_lookup_or_create(struct mail_index *index, |
a1c587d3d633
Removed autocreate parameter from mail_index_keyword_lookup(). Added a new
Timo Sirainen <tss@iki.fi>
parents:
6330
diff
changeset
|
233 const char *keyword, |
a1c587d3d633
Removed autocreate parameter from mail_index_keyword_lookup(). Added a new
Timo Sirainen <tss@iki.fi>
parents:
6330
diff
changeset
|
234 unsigned int *idx_r) |
a1c587d3d633
Removed autocreate parameter from mail_index_keyword_lookup(). Added a new
Timo Sirainen <tss@iki.fi>
parents:
6330
diff
changeset
|
235 { |
a1c587d3d633
Removed autocreate parameter from mail_index_keyword_lookup(). Added a new
Timo Sirainen <tss@iki.fi>
parents:
6330
diff
changeset
|
236 char *keyword_dup; |
a1c587d3d633
Removed autocreate parameter from mail_index_keyword_lookup(). Added a new
Timo Sirainen <tss@iki.fi>
parents:
6330
diff
changeset
|
237 |
6350
e7f61751822e
Added assert against empty keyword.
Timo Sirainen <tss@iki.fi>
parents:
6349
diff
changeset
|
238 i_assert(*keyword != '\0'); |
e7f61751822e
Added assert against empty keyword.
Timo Sirainen <tss@iki.fi>
parents:
6349
diff
changeset
|
239 |
6335
a1c587d3d633
Removed autocreate parameter from mail_index_keyword_lookup(). Added a new
Timo Sirainen <tss@iki.fi>
parents:
6330
diff
changeset
|
240 if (mail_index_keyword_lookup(index, keyword, idx_r)) |
a1c587d3d633
Removed autocreate parameter from mail_index_keyword_lookup(). Added a new
Timo Sirainen <tss@iki.fi>
parents:
6330
diff
changeset
|
241 return; |
3254
a2943c050571
Keywords are now stored in X-Keywords headers in mbox. Did several related
Timo Sirainen <tss@iki.fi>
parents:
3243
diff
changeset
|
242 |
a2943c050571
Keywords are now stored in X-Keywords headers in mbox. Did several related
Timo Sirainen <tss@iki.fi>
parents:
3243
diff
changeset
|
243 keyword = keyword_dup = p_strdup(index->keywords_pool, keyword); |
a2943c050571
Keywords are now stored in X-Keywords headers in mbox. Did several related
Timo Sirainen <tss@iki.fi>
parents:
3243
diff
changeset
|
244 *idx_r = array_count(&index->keywords); |
a2943c050571
Keywords are now stored in X-Keywords headers in mbox. Did several related
Timo Sirainen <tss@iki.fi>
parents:
3243
diff
changeset
|
245 |
8573
f9166a09423a
Renamed hash_*() to hash_table_*() to avoid conflicts with OSX's strhash.h
Timo Sirainen <tss@iki.fi>
parents:
8572
diff
changeset
|
246 hash_table_insert(index->keywords_hash, |
f9166a09423a
Renamed hash_*() to hash_table_*() to avoid conflicts with OSX's strhash.h
Timo Sirainen <tss@iki.fi>
parents:
8572
diff
changeset
|
247 keyword_dup, POINTER_CAST(*idx_r)); |
3254
a2943c050571
Keywords are now stored in X-Keywords headers in mbox. Did several related
Timo Sirainen <tss@iki.fi>
parents:
3243
diff
changeset
|
248 array_append(&index->keywords, &keyword, 1); |
a2943c050571
Keywords are now stored in X-Keywords headers in mbox. Did several related
Timo Sirainen <tss@iki.fi>
parents:
3243
diff
changeset
|
249 } |
a2943c050571
Keywords are now stored in X-Keywords headers in mbox. Did several related
Timo Sirainen <tss@iki.fi>
parents:
3243
diff
changeset
|
250 |
4451
1a35d53c18fc
Array API redesigned to work using unions. It now provides type safety
Timo Sirainen <tss@iki.fi>
parents:
4396
diff
changeset
|
251 const ARRAY_TYPE(keywords) *mail_index_get_keywords(struct mail_index *index) |
3016
61c8d205d887
Initial support for keywords. Syncing to mbox/maildir doesn't work yet.
Timo Sirainen <tss@iki.fi>
parents:
2956
diff
changeset
|
252 { |
3254
a2943c050571
Keywords are now stored in X-Keywords headers in mbox. Did several related
Timo Sirainen <tss@iki.fi>
parents:
3243
diff
changeset
|
253 return &index->keywords; |
3016
61c8d205d887
Initial support for keywords. Syncing to mbox/maildir doesn't work yet.
Timo Sirainen <tss@iki.fi>
parents:
2956
diff
changeset
|
254 } |
61c8d205d887
Initial support for keywords. Syncing to mbox/maildir doesn't work yet.
Timo Sirainen <tss@iki.fi>
parents:
2956
diff
changeset
|
255 |
5686
0d2a6a7f2a1b
Moved mail index map related code to its own file.
Timo Sirainen <tss@iki.fi>
parents:
5666
diff
changeset
|
256 int mail_index_try_open_only(struct mail_index *index) |
2063
21a3e5d08290
mail_index_refresh() - allows forcing a refresh check
Timo Sirainen <tss@iki.fi>
parents:
2051
diff
changeset
|
257 { |
5689
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
258 i_assert(index->fd == -1); |
3243
40b4ba3c55b8
In-memory indexes work again. Just pass dir as NULL to mail_index_alloc().
Timo Sirainen <tss@iki.fi>
parents:
3231
diff
changeset
|
259 i_assert(!MAIL_INDEX_IS_IN_MEMORY(index)); |
40b4ba3c55b8
In-memory indexes work again. Just pass dir as NULL to mail_index_alloc().
Timo Sirainen <tss@iki.fi>
parents:
3231
diff
changeset
|
260 |
5689
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
261 /* Note that our caller must close index->fd by itself. */ |
6686
610f3d9813b5
Added MAIL_INDEX_OPEN_FLAG_READONLY.
Timo Sirainen <tss@iki.fi>
parents:
6679
diff
changeset
|
262 if (index->readonly) |
610f3d9813b5
Added MAIL_INDEX_OPEN_FLAG_READONLY.
Timo Sirainen <tss@iki.fi>
parents:
6679
diff
changeset
|
263 errno = EACCES; |
610f3d9813b5
Added MAIL_INDEX_OPEN_FLAG_READONLY.
Timo Sirainen <tss@iki.fi>
parents:
6679
diff
changeset
|
264 else { |
610f3d9813b5
Added MAIL_INDEX_OPEN_FLAG_READONLY.
Timo Sirainen <tss@iki.fi>
parents:
6679
diff
changeset
|
265 index->fd = nfs_safe_open(index->filepath, O_RDWR); |
610f3d9813b5
Added MAIL_INDEX_OPEN_FLAG_READONLY.
Timo Sirainen <tss@iki.fi>
parents:
6679
diff
changeset
|
266 index->readonly = FALSE; |
610f3d9813b5
Added MAIL_INDEX_OPEN_FLAG_READONLY.
Timo Sirainen <tss@iki.fi>
parents:
6679
diff
changeset
|
267 } |
2063
21a3e5d08290
mail_index_refresh() - allows forcing a refresh check
Timo Sirainen <tss@iki.fi>
parents:
2051
diff
changeset
|
268 |
4023
b19ccbaa3802
Try to handle ESTALE NFS errors the best way we can.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3912
diff
changeset
|
269 if (index->fd == -1 && errno == EACCES) { |
b19ccbaa3802
Try to handle ESTALE NFS errors the best way we can.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3912
diff
changeset
|
270 index->fd = open(index->filepath, O_RDONLY); |
b19ccbaa3802
Try to handle ESTALE NFS errors the best way we can.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3912
diff
changeset
|
271 index->readonly = TRUE; |
2063
21a3e5d08290
mail_index_refresh() - allows forcing a refresh check
Timo Sirainen <tss@iki.fi>
parents:
2051
diff
changeset
|
272 } |
4023
b19ccbaa3802
Try to handle ESTALE NFS errors the best way we can.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3912
diff
changeset
|
273 |
2063
21a3e5d08290
mail_index_refresh() - allows forcing a refresh check
Timo Sirainen <tss@iki.fi>
parents:
2051
diff
changeset
|
274 if (index->fd == -1) { |
21a3e5d08290
mail_index_refresh() - allows forcing a refresh check
Timo Sirainen <tss@iki.fi>
parents:
2051
diff
changeset
|
275 if (errno != ENOENT) |
21a3e5d08290
mail_index_refresh() - allows forcing a refresh check
Timo Sirainen <tss@iki.fi>
parents:
2051
diff
changeset
|
276 return mail_index_set_syscall_error(index, "open()"); |
21a3e5d08290
mail_index_refresh() - allows forcing a refresh check
Timo Sirainen <tss@iki.fi>
parents:
2051
diff
changeset
|
277 |
21a3e5d08290
mail_index_refresh() - allows forcing a refresh check
Timo Sirainen <tss@iki.fi>
parents:
2051
diff
changeset
|
278 /* have to create it */ |
21a3e5d08290
mail_index_refresh() - allows forcing a refresh check
Timo Sirainen <tss@iki.fi>
parents:
2051
diff
changeset
|
279 return 0; |
21a3e5d08290
mail_index_refresh() - allows forcing a refresh check
Timo Sirainen <tss@iki.fi>
parents:
2051
diff
changeset
|
280 } |
21a3e5d08290
mail_index_refresh() - allows forcing a refresh check
Timo Sirainen <tss@iki.fi>
parents:
2051
diff
changeset
|
281 return 1; |
21a3e5d08290
mail_index_refresh() - allows forcing a refresh check
Timo Sirainen <tss@iki.fi>
parents:
2051
diff
changeset
|
282 } |
21a3e5d08290
mail_index_refresh() - allows forcing a refresh check
Timo Sirainen <tss@iki.fi>
parents:
2051
diff
changeset
|
283 |
21a3e5d08290
mail_index_refresh() - allows forcing a refresh check
Timo Sirainen <tss@iki.fi>
parents:
2051
diff
changeset
|
284 static int |
5689
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
285 mail_index_try_open(struct mail_index *index) |
2063
21a3e5d08290
mail_index_refresh() - allows forcing a refresh check
Timo Sirainen <tss@iki.fi>
parents:
2051
diff
changeset
|
286 { |
21a3e5d08290
mail_index_refresh() - allows forcing a refresh check
Timo Sirainen <tss@iki.fi>
parents:
2051
diff
changeset
|
287 int ret; |
21a3e5d08290
mail_index_refresh() - allows forcing a refresh check
Timo Sirainen <tss@iki.fi>
parents:
2051
diff
changeset
|
288 |
4023
b19ccbaa3802
Try to handle ESTALE NFS errors the best way we can.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3912
diff
changeset
|
289 i_assert(index->fd == -1); |
2063
21a3e5d08290
mail_index_refresh() - allows forcing a refresh check
Timo Sirainen <tss@iki.fi>
parents:
2051
diff
changeset
|
290 |
3243
40b4ba3c55b8
In-memory indexes work again. Just pass dir as NULL to mail_index_alloc().
Timo Sirainen <tss@iki.fi>
parents:
3231
diff
changeset
|
291 if (MAIL_INDEX_IS_IN_MEMORY(index)) |
40b4ba3c55b8
In-memory indexes work again. Just pass dir as NULL to mail_index_alloc().
Timo Sirainen <tss@iki.fi>
parents:
3231
diff
changeset
|
292 return 0; |
40b4ba3c55b8
In-memory indexes work again. Just pass dir as NULL to mail_index_alloc().
Timo Sirainen <tss@iki.fi>
parents:
3231
diff
changeset
|
293 |
6165
6418139447fa
Created a new struct mail_index_record_map which can be shared by multiple
Timo Sirainen <tss@iki.fi>
parents:
6022
diff
changeset
|
294 i_assert(index->map == NULL || index->map->rec_map->lock_id == 0); |
5854 | 295 ret = mail_index_map(index, MAIL_INDEX_SYNC_HANDLER_HEAD); |
2063
21a3e5d08290
mail_index_refresh() - allows forcing a refresh check
Timo Sirainen <tss@iki.fi>
parents:
2051
diff
changeset
|
296 if (ret == 0) { |
21a3e5d08290
mail_index_refresh() - allows forcing a refresh check
Timo Sirainen <tss@iki.fi>
parents:
2051
diff
changeset
|
297 /* it's corrupted - recreate it */ |
5820
e59892590a02
Handle losing index file better. Handle fsck better.
Timo Sirainen <tss@iki.fi>
parents:
5819
diff
changeset
|
298 if (index->fd != -1) { |
e59892590a02
Handle losing index file better. Handle fsck better.
Timo Sirainen <tss@iki.fi>
parents:
5819
diff
changeset
|
299 if (close(index->fd) < 0) |
e59892590a02
Handle losing index file better. Handle fsck better.
Timo Sirainen <tss@iki.fi>
parents:
5819
diff
changeset
|
300 mail_index_set_syscall_error(index, "close()"); |
e59892590a02
Handle losing index file better. Handle fsck better.
Timo Sirainen <tss@iki.fi>
parents:
5819
diff
changeset
|
301 index->fd = -1; |
e59892590a02
Handle losing index file better. Handle fsck better.
Timo Sirainen <tss@iki.fi>
parents:
5819
diff
changeset
|
302 } |
2063
21a3e5d08290
mail_index_refresh() - allows forcing a refresh check
Timo Sirainen <tss@iki.fi>
parents:
2051
diff
changeset
|
303 } |
21a3e5d08290
mail_index_refresh() - allows forcing a refresh check
Timo Sirainen <tss@iki.fi>
parents:
2051
diff
changeset
|
304 return ret; |
21a3e5d08290
mail_index_refresh() - allows forcing a refresh check
Timo Sirainen <tss@iki.fi>
parents:
2051
diff
changeset
|
305 } |
21a3e5d08290
mail_index_refresh() - allows forcing a refresh check
Timo Sirainen <tss@iki.fi>
parents:
2051
diff
changeset
|
306 |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
307 int mail_index_create_tmp_file(struct mail_index *index, const char **path_r) |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
308 { |
2879
aa93c7216722
dovecot-shared file was supposed to show permissions/gid for files created
Timo Sirainen <tss@iki.fi>
parents:
2877
diff
changeset
|
309 mode_t old_mask; |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
310 const char *path; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
311 int fd; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
312 |
3243
40b4ba3c55b8
In-memory indexes work again. Just pass dir as NULL to mail_index_alloc().
Timo Sirainen <tss@iki.fi>
parents:
3231
diff
changeset
|
313 i_assert(!MAIL_INDEX_IS_IN_MEMORY(index)); |
40b4ba3c55b8
In-memory indexes work again. Just pass dir as NULL to mail_index_alloc().
Timo Sirainen <tss@iki.fi>
parents:
3231
diff
changeset
|
314 |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
315 path = *path_r = t_strconcat(index->filepath, ".tmp", NULL); |
2879
aa93c7216722
dovecot-shared file was supposed to show permissions/gid for files created
Timo Sirainen <tss@iki.fi>
parents:
2877
diff
changeset
|
316 old_mask = umask(0); |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
317 fd = open(path, O_RDWR|O_CREAT|O_TRUNC, index->mode); |
2879
aa93c7216722
dovecot-shared file was supposed to show permissions/gid for files created
Timo Sirainen <tss@iki.fi>
parents:
2877
diff
changeset
|
318 umask(old_mask); |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
319 if (fd == -1) |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
320 return mail_index_file_set_syscall_error(index, path, "open()"); |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
321 |
9420
c496f137c843
index: Handle better errors where a new file's group can't be changed.
Timo Sirainen <tss@iki.fi>
parents:
9394
diff
changeset
|
322 mail_index_fchown(index, fd, path); |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
323 return fd; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
324 } |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
325 |
6375
fc2f5607108d
fsck the index while it's being mapped.
Timo Sirainen <tss@iki.fi>
parents:
6372
diff
changeset
|
326 static int mail_index_open_files(struct mail_index *index, |
fc2f5607108d
fsck the index while it's being mapped.
Timo Sirainen <tss@iki.fi>
parents:
6372
diff
changeset
|
327 enum mail_index_open_flags flags) |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
328 { |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
329 int ret; |
5689
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
330 bool created = FALSE; |
3582
bfa542369fdc
When creating a new index file, mark its log offsets so that the possibly
Timo Sirainen <tss@iki.fi>
parents:
3556
diff
changeset
|
331 |
5689
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
332 ret = mail_transaction_log_open(index->log); |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
333 if (ret == 0) { |
5689
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
334 if ((flags & MAIL_INDEX_OPEN_FLAG_CREATE) == 0) |
6375
fc2f5607108d
fsck the index while it's being mapped.
Timo Sirainen <tss@iki.fi>
parents:
6372
diff
changeset
|
335 return 0; |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
336 |
5819 | 337 /* if dovecot.index exists, read it first so that we can get |
338 the correct indexid and log sequence */ | |
339 (void)mail_index_try_open(index); | |
340 | |
341 if (index->indexid == 0) { | |
6359
c54c07f30a97
Fixed opening indexes to memory.
Timo Sirainen <tss@iki.fi>
parents:
6350
diff
changeset
|
342 /* Create a new indexid for us. If we're opening index |
c54c07f30a97
Fixed opening indexes to memory.
Timo Sirainen <tss@iki.fi>
parents:
6350
diff
changeset
|
343 into memory, index->map doesn't exist yet. */ |
5819 | 344 index->indexid = ioloop_time; |
7573
de08cc81da73
Fixes to handling races in initial index creation.
Timo Sirainen <tss@iki.fi>
parents:
7361
diff
changeset
|
345 index->initial_create = TRUE; |
6359
c54c07f30a97
Fixed opening indexes to memory.
Timo Sirainen <tss@iki.fi>
parents:
6350
diff
changeset
|
346 if (index->map != NULL) |
c54c07f30a97
Fixed opening indexes to memory.
Timo Sirainen <tss@iki.fi>
parents:
6350
diff
changeset
|
347 index->map->hdr.indexid = index->indexid; |
5819 | 348 } |
349 | |
7573
de08cc81da73
Fixes to handling races in initial index creation.
Timo Sirainen <tss@iki.fi>
parents:
7361
diff
changeset
|
350 ret = mail_transaction_log_create(index->log, FALSE); |
de08cc81da73
Fixes to handling races in initial index creation.
Timo Sirainen <tss@iki.fi>
parents:
7361
diff
changeset
|
351 index->initial_create = FALSE; |
5689
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
352 created = TRUE; |
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
353 } |
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
354 if (ret >= 0) { |
7573
de08cc81da73
Fixes to handling races in initial index creation.
Timo Sirainen <tss@iki.fi>
parents:
7361
diff
changeset
|
355 ret = index->map != NULL ? 1 : mail_index_try_open(index); |
5689
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
356 if (ret == 0) { |
7573
de08cc81da73
Fixes to handling races in initial index creation.
Timo Sirainen <tss@iki.fi>
parents:
7361
diff
changeset
|
357 /* corrupted */ |
6322
8d9a156ec94e
Handle opening corrupted index files better.
Timo Sirainen <tss@iki.fi>
parents:
6321
diff
changeset
|
358 mail_transaction_log_close(index->log); |
7573
de08cc81da73
Fixes to handling races in initial index creation.
Timo Sirainen <tss@iki.fi>
parents:
7361
diff
changeset
|
359 ret = mail_transaction_log_create(index->log, TRUE); |
6359
c54c07f30a97
Fixed opening indexes to memory.
Timo Sirainen <tss@iki.fi>
parents:
6350
diff
changeset
|
360 if (ret == 0) { |
c54c07f30a97
Fixed opening indexes to memory.
Timo Sirainen <tss@iki.fi>
parents:
6350
diff
changeset
|
361 if (index->map != NULL) |
c54c07f30a97
Fixed opening indexes to memory.
Timo Sirainen <tss@iki.fi>
parents:
6350
diff
changeset
|
362 mail_index_unmap(&index->map); |
6322
8d9a156ec94e
Handle opening corrupted index files better.
Timo Sirainen <tss@iki.fi>
parents:
6321
diff
changeset
|
363 index->map = mail_index_map_alloc(index); |
6359
c54c07f30a97
Fixed opening indexes to memory.
Timo Sirainen <tss@iki.fi>
parents:
6350
diff
changeset
|
364 } |
2170 | 365 } |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
366 } |
5689
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
367 if (ret < 0) { |
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
368 /* open/create failed, fallback to in-memory indexes */ |
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
369 if ((flags & MAIL_INDEX_OPEN_FLAG_CREATE) == 0) |
6375
fc2f5607108d
fsck the index while it's being mapped.
Timo Sirainen <tss@iki.fi>
parents:
6372
diff
changeset
|
370 return -1; |
3243
40b4ba3c55b8
In-memory indexes work again. Just pass dir as NULL to mail_index_alloc().
Timo Sirainen <tss@iki.fi>
parents:
3231
diff
changeset
|
371 |
5689
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
372 if (mail_index_move_to_memory(index) < 0) |
6375
fc2f5607108d
fsck the index while it's being mapped.
Timo Sirainen <tss@iki.fi>
parents:
6372
diff
changeset
|
373 return -1; |
2200
97bb7b127617
Beginnings of getting cache file working again. Easy to break currently, but
Timo Sirainen <tss@iki.fi>
parents:
2193
diff
changeset
|
374 } |
97bb7b127617
Beginnings of getting cache file working again. Easy to break currently, but
Timo Sirainen <tss@iki.fi>
parents:
2193
diff
changeset
|
375 |
3129
1ea614abead3
Don't complain about cache indexid changing when recreating index.
Timo Sirainen <tss@iki.fi>
parents:
3105
diff
changeset
|
376 index->cache = created ? mail_cache_create(index) : |
1ea614abead3
Don't complain about cache indexid changing when recreating index.
Timo Sirainen <tss@iki.fi>
parents:
3105
diff
changeset
|
377 mail_cache_open_or_create(index); |
6375
fc2f5607108d
fsck the index while it's being mapped.
Timo Sirainen <tss@iki.fi>
parents:
6372
diff
changeset
|
378 return 1; |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
379 } |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
380 |
2723
12b503fbb8af
Replaced fcntl_locks_disable with lock_method, so it's now possible to use
Timo Sirainen <tss@iki.fi>
parents:
2715
diff
changeset
|
381 int mail_index_open(struct mail_index *index, enum mail_index_open_flags flags, |
4876
f1d77064884c
Lock handling changes. Everything goes through file-lock API now and there's
Timo Sirainen <tss@iki.fi>
parents:
4795
diff
changeset
|
382 enum file_lock_method lock_method) |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
383 { |
6375
fc2f5607108d
fsck the index while it's being mapped.
Timo Sirainen <tss@iki.fi>
parents:
6372
diff
changeset
|
384 int ret; |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
385 |
2926
c035583b4839
Make sure index is reopened if it's marked corrupted.
Timo Sirainen <tss@iki.fi>
parents:
2922
diff
changeset
|
386 if (index->opened) { |
5772
002aa9bbfcb2
Removed index->hdr. Use index->map->hdr instead.
Timo Sirainen <tss@iki.fi>
parents:
5714
diff
changeset
|
387 if (index->map != NULL && |
002aa9bbfcb2
Removed index->hdr. Use index->map->hdr instead.
Timo Sirainen <tss@iki.fi>
parents:
5714
diff
changeset
|
388 (index->map->hdr.flags & |
002aa9bbfcb2
Removed index->hdr. Use index->map->hdr instead.
Timo Sirainen <tss@iki.fi>
parents:
5714
diff
changeset
|
389 MAIL_INDEX_HDR_FLAG_CORRUPTED) != 0) { |
2926
c035583b4839
Make sure index is reopened if it's marked corrupted.
Timo Sirainen <tss@iki.fi>
parents:
2922
diff
changeset
|
390 /* corrupted, reopen files */ |
c035583b4839
Make sure index is reopened if it's marked corrupted.
Timo Sirainen <tss@iki.fi>
parents:
2922
diff
changeset
|
391 mail_index_close(index); |
c035583b4839
Make sure index is reopened if it's marked corrupted.
Timo Sirainen <tss@iki.fi>
parents:
2922
diff
changeset
|
392 } else { |
5689
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
393 i_assert(index->map != NULL); |
4067
96ae9c096bde
mail_index_open(): If index is already open, return 1 instead of 0 so the
Timo Sirainen <tss@iki.fi>
parents:
4053
diff
changeset
|
394 return 1; |
2926
c035583b4839
Make sure index is reopened if it's marked corrupted.
Timo Sirainen <tss@iki.fi>
parents:
2922
diff
changeset
|
395 } |
c035583b4839
Make sure index is reopened if it's marked corrupted.
Timo Sirainen <tss@iki.fi>
parents:
2922
diff
changeset
|
396 } |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
397 |
3243
40b4ba3c55b8
In-memory indexes work again. Just pass dir as NULL to mail_index_alloc().
Timo Sirainen <tss@iki.fi>
parents:
3231
diff
changeset
|
398 index->filepath = MAIL_INDEX_IS_IN_MEMORY(index) ? |
40b4ba3c55b8
In-memory indexes work again. Just pass dir as NULL to mail_index_alloc().
Timo Sirainen <tss@iki.fi>
parents:
3231
diff
changeset
|
399 i_strdup("(in-memory index)") : |
40b4ba3c55b8
In-memory indexes work again. Just pass dir as NULL to mail_index_alloc().
Timo Sirainen <tss@iki.fi>
parents:
3231
diff
changeset
|
400 i_strconcat(index->dir, "/", index->prefix, NULL); |
1967 | 401 |
6375
fc2f5607108d
fsck the index while it's being mapped.
Timo Sirainen <tss@iki.fi>
parents:
6372
diff
changeset
|
402 index->shared_lock_count = 0; |
fc2f5607108d
fsck the index while it's being mapped.
Timo Sirainen <tss@iki.fi>
parents:
6372
diff
changeset
|
403 index->excl_lock_count = 0; |
fc2f5607108d
fsck the index while it's being mapped.
Timo Sirainen <tss@iki.fi>
parents:
6372
diff
changeset
|
404 index->lock_type = F_UNLCK; |
fc2f5607108d
fsck the index while it's being mapped.
Timo Sirainen <tss@iki.fi>
parents:
6372
diff
changeset
|
405 index->lock_id_counter = 2; |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
406 |
6375
fc2f5607108d
fsck the index while it's being mapped.
Timo Sirainen <tss@iki.fi>
parents:
6372
diff
changeset
|
407 index->readonly = FALSE; |
fc2f5607108d
fsck the index while it's being mapped.
Timo Sirainen <tss@iki.fi>
parents:
6372
diff
changeset
|
408 index->nodiskspace = FALSE; |
fc2f5607108d
fsck the index while it's being mapped.
Timo Sirainen <tss@iki.fi>
parents:
6372
diff
changeset
|
409 index->index_lock_timeout = FALSE; |
fc2f5607108d
fsck the index while it's being mapped.
Timo Sirainen <tss@iki.fi>
parents:
6372
diff
changeset
|
410 index->log_locked = FALSE; |
fc2f5607108d
fsck the index while it's being mapped.
Timo Sirainen <tss@iki.fi>
parents:
6372
diff
changeset
|
411 index->mmap_disable = (flags & MAIL_INDEX_OPEN_FLAG_MMAP_DISABLE) != 0; |
fc2f5607108d
fsck the index while it's being mapped.
Timo Sirainen <tss@iki.fi>
parents:
6372
diff
changeset
|
412 index->use_excl_dotlocks = |
fc2f5607108d
fsck the index while it's being mapped.
Timo Sirainen <tss@iki.fi>
parents:
6372
diff
changeset
|
413 (flags & MAIL_INDEX_OPEN_FLAG_DOTLOCK_USE_EXCL) != 0; |
fc2f5607108d
fsck the index while it's being mapped.
Timo Sirainen <tss@iki.fi>
parents:
6372
diff
changeset
|
414 index->fsync_disable = |
fc2f5607108d
fsck the index while it's being mapped.
Timo Sirainen <tss@iki.fi>
parents:
6372
diff
changeset
|
415 (flags & MAIL_INDEX_OPEN_FLAG_FSYNC_DISABLE) != 0; |
fc2f5607108d
fsck the index while it's being mapped.
Timo Sirainen <tss@iki.fi>
parents:
6372
diff
changeset
|
416 index->nfs_flush = (flags & MAIL_INDEX_OPEN_FLAG_NFS_FLUSH) != 0; |
6686
610f3d9813b5
Added MAIL_INDEX_OPEN_FLAG_READONLY.
Timo Sirainen <tss@iki.fi>
parents:
6679
diff
changeset
|
417 index->readonly = (flags & MAIL_INDEX_OPEN_FLAG_READONLY) != 0; |
8960
63a75a03360c
dbox: Create dovecot.index.backup files.
Timo Sirainen <tss@iki.fi>
parents:
8953
diff
changeset
|
418 index->keep_backups = (flags & MAIL_INDEX_OPEN_FLAG_KEEP_BACKUPS) != 0; |
8973
f295678cef1e
dbox: Make sure indexes are never moved to memory (in case of out-of-disk space).
Timo Sirainen <tss@iki.fi>
parents:
8960
diff
changeset
|
419 index->never_in_memory = |
f295678cef1e
dbox: Make sure indexes are never moved to memory (in case of out-of-disk space).
Timo Sirainen <tss@iki.fi>
parents:
8960
diff
changeset
|
420 (flags & MAIL_INDEX_OPEN_FLAG_NEVER_IN_MEMORY) != 0; |
6375
fc2f5607108d
fsck the index while it's being mapped.
Timo Sirainen <tss@iki.fi>
parents:
6372
diff
changeset
|
421 index->lock_method = lock_method; |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
422 |
6375
fc2f5607108d
fsck the index while it's being mapped.
Timo Sirainen <tss@iki.fi>
parents:
6372
diff
changeset
|
423 if (index->nfs_flush && index->fsync_disable) |
fc2f5607108d
fsck the index while it's being mapped.
Timo Sirainen <tss@iki.fi>
parents:
6372
diff
changeset
|
424 i_fatal("nfs flush requires fsync_disable=no"); |
fc2f5607108d
fsck the index while it's being mapped.
Timo Sirainen <tss@iki.fi>
parents:
6372
diff
changeset
|
425 if (index->nfs_flush && !index->mmap_disable) |
fc2f5607108d
fsck the index while it's being mapped.
Timo Sirainen <tss@iki.fi>
parents:
6372
diff
changeset
|
426 i_fatal("nfs flush requires mmap_disable=yes"); |
fc2f5607108d
fsck the index while it's being mapped.
Timo Sirainen <tss@iki.fi>
parents:
6372
diff
changeset
|
427 |
fc2f5607108d
fsck the index while it's being mapped.
Timo Sirainen <tss@iki.fi>
parents:
6372
diff
changeset
|
428 if ((ret = mail_index_open_files(index, flags)) <= 0) { |
fc2f5607108d
fsck the index while it's being mapped.
Timo Sirainen <tss@iki.fi>
parents:
6372
diff
changeset
|
429 /* doesn't exist and create flag not used */ |
fc2f5607108d
fsck the index while it's being mapped.
Timo Sirainen <tss@iki.fi>
parents:
6372
diff
changeset
|
430 mail_index_close(index); |
fc2f5607108d
fsck the index while it's being mapped.
Timo Sirainen <tss@iki.fi>
parents:
6372
diff
changeset
|
431 return ret; |
3824
3e756ea0474b
Comment updates, small cleanups and optimizations.
Timo Sirainen <tss@iki.fi>
parents:
3819
diff
changeset
|
432 } |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
433 |
6375
fc2f5607108d
fsck the index while it's being mapped.
Timo Sirainen <tss@iki.fi>
parents:
6372
diff
changeset
|
434 i_assert(index->map != NULL); |
fc2f5607108d
fsck the index while it's being mapped.
Timo Sirainen <tss@iki.fi>
parents:
6372
diff
changeset
|
435 index->opened = TRUE; |
fc2f5607108d
fsck the index while it's being mapped.
Timo Sirainen <tss@iki.fi>
parents:
6372
diff
changeset
|
436 return 1; |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
437 } |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
438 |
8953
f80f26822262
Added mail_index_open_or_create().
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
439 int mail_index_open_or_create(struct mail_index *index, |
f80f26822262
Added mail_index_open_or_create().
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
440 enum mail_index_open_flags flags, |
f80f26822262
Added mail_index_open_or_create().
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
441 enum file_lock_method lock_method) |
f80f26822262
Added mail_index_open_or_create().
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
442 { |
f80f26822262
Added mail_index_open_or_create().
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
443 int ret; |
f80f26822262
Added mail_index_open_or_create().
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
444 |
f80f26822262
Added mail_index_open_or_create().
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
445 flags |= MAIL_INDEX_OPEN_FLAG_CREATE; |
f80f26822262
Added mail_index_open_or_create().
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
446 ret = mail_index_open(index, flags, lock_method); |
f80f26822262
Added mail_index_open_or_create().
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
447 i_assert(ret != 0); |
f80f26822262
Added mail_index_open_or_create().
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
448 return ret < 0 ? -1 : 0; |
f80f26822262
Added mail_index_open_or_create().
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
449 } |
f80f26822262
Added mail_index_open_or_create().
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
450 |
6390
ff48b008150f
Fix ESTALE handling when reading main index.
Timo Sirainen <tss@iki.fi>
parents:
6384
diff
changeset
|
451 void mail_index_close_file(struct mail_index *index) |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
452 { |
4876
f1d77064884c
Lock handling changes. Everything goes through file-lock API now and there's
Timo Sirainen <tss@iki.fi>
parents:
4795
diff
changeset
|
453 if (index->file_lock != NULL) |
f1d77064884c
Lock handling changes. Everything goes through file-lock API now and there's
Timo Sirainen <tss@iki.fi>
parents:
4795
diff
changeset
|
454 file_lock_free(&index->file_lock); |
2200
97bb7b127617
Beginnings of getting cache file working again. Easy to break currently, but
Timo Sirainen <tss@iki.fi>
parents:
2193
diff
changeset
|
455 |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
456 if (index->fd != -1) { |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
457 if (close(index->fd) < 0) |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
458 mail_index_set_syscall_error(index, "close()"); |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
459 index->fd = -1; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
460 } |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
461 |
5854 | 462 index->lock_id_counter += 2; |
6372
f33ea6ff46ea
Drop also exclusive locks when closing index files (there shouldn't be any
Timo Sirainen <tss@iki.fi>
parents:
6371
diff
changeset
|
463 index->lock_type = F_UNLCK; |
5689
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
464 index->shared_lock_count = 0; |
6372
f33ea6ff46ea
Drop also exclusive locks when closing index files (there shouldn't be any
Timo Sirainen <tss@iki.fi>
parents:
6371
diff
changeset
|
465 index->excl_lock_count = 0; |
5689
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
466 } |
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
467 |
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
468 void mail_index_close(struct mail_index *index) |
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
469 { |
5827 | 470 if (index->map != NULL) |
5853
d9f319a9d6e0
mail_index_map now contains pointer to index, so all functions taking map
Timo Sirainen <tss@iki.fi>
parents:
5827
diff
changeset
|
471 mail_index_unmap(&index->map); |
5827 | 472 |
473 mail_index_close_file(index); | |
5689
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
474 mail_transaction_log_close(index->log); |
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
475 if (index->cache != NULL) |
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
476 mail_cache_free(&index->cache); |
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
477 |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
478 i_free_and_null(index->filepath); |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
479 |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
480 index->indexid = 0; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
481 index->opened = FALSE; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
482 } |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
483 |
9311 | 484 int mail_index_unlink(struct mail_index *index) |
485 { | |
486 const char *path; | |
487 int last_errno = 0; | |
488 | |
489 if (MAIL_INDEX_IS_IN_MEMORY(index)) | |
490 return 0; | |
491 | |
492 /* main index */ | |
493 if (unlink(index->filepath) < 0 && errno != ENOENT) | |
494 last_errno = errno; | |
495 | |
496 /* logs */ | |
497 path = t_strconcat(index->filepath, MAIL_TRANSACTION_LOG_SUFFIX, NULL); | |
498 if (unlink(path) < 0 && errno != ENOENT) | |
499 last_errno = errno; | |
500 | |
501 path = t_strconcat(index->filepath, | |
502 MAIL_TRANSACTION_LOG_SUFFIX".2", NULL); | |
503 if (unlink(path) < 0 && errno != ENOENT) | |
504 last_errno = errno; | |
505 | |
506 /* cache */ | |
507 path = t_strconcat(index->filepath, MAIL_CACHE_FILE_SUFFIX, NULL); | |
508 if (unlink(path) < 0 && errno != ENOENT) | |
509 last_errno = errno; | |
510 | |
511 if (last_errno == 0) | |
512 return 0; | |
513 else { | |
514 errno = last_errno; | |
515 return -1; | |
516 } | |
517 } | |
518 | |
5689
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
519 int mail_index_reopen_if_changed(struct mail_index *index) |
2063
21a3e5d08290
mail_index_refresh() - allows forcing a refresh check
Timo Sirainen <tss@iki.fi>
parents:
2051
diff
changeset
|
520 { |
21a3e5d08290
mail_index_refresh() - allows forcing a refresh check
Timo Sirainen <tss@iki.fi>
parents:
2051
diff
changeset
|
521 struct stat st1, st2; |
21a3e5d08290
mail_index_refresh() - allows forcing a refresh check
Timo Sirainen <tss@iki.fi>
parents:
2051
diff
changeset
|
522 |
6829
dbab5e592577
NFS cache flushing APIs changed and backend implements it a bit differently.
Timo Sirainen <tss@iki.fi>
parents:
6819
diff
changeset
|
523 i_assert(index->shared_lock_count == 0 || !index->nfs_flush); |
5689
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
524 i_assert(index->excl_lock_count == 0); |
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
525 |
3243
40b4ba3c55b8
In-memory indexes work again. Just pass dir as NULL to mail_index_alloc().
Timo Sirainen <tss@iki.fi>
parents:
3231
diff
changeset
|
526 if (MAIL_INDEX_IS_IN_MEMORY(index)) |
40b4ba3c55b8
In-memory indexes work again. Just pass dir as NULL to mail_index_alloc().
Timo Sirainen <tss@iki.fi>
parents:
3231
diff
changeset
|
527 return 0; |
40b4ba3c55b8
In-memory indexes work again. Just pass dir as NULL to mail_index_alloc().
Timo Sirainen <tss@iki.fi>
parents:
3231
diff
changeset
|
528 |
5689
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
529 if (index->fd == -1) |
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
530 return mail_index_try_open_only(index); |
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
531 |
6797
a59deefc552f
NFS attribute cache flushing fixes. nfs_flush_attr_cache() takes now
Timo Sirainen <tss@iki.fi>
parents:
6755
diff
changeset
|
532 if (index->nfs_flush) |
6857 | 533 nfs_flush_file_handle_cache(index->filepath); |
6797
a59deefc552f
NFS attribute cache flushing fixes. nfs_flush_attr_cache() takes now
Timo Sirainen <tss@iki.fi>
parents:
6755
diff
changeset
|
534 if (nfs_safe_stat(index->filepath, &st2) < 0) { |
a59deefc552f
NFS attribute cache flushing fixes. nfs_flush_attr_cache() takes now
Timo Sirainen <tss@iki.fi>
parents:
6755
diff
changeset
|
535 if (errno == ENOENT) |
a59deefc552f
NFS attribute cache flushing fixes. nfs_flush_attr_cache() takes now
Timo Sirainen <tss@iki.fi>
parents:
6755
diff
changeset
|
536 return 0; |
a59deefc552f
NFS attribute cache flushing fixes. nfs_flush_attr_cache() takes now
Timo Sirainen <tss@iki.fi>
parents:
6755
diff
changeset
|
537 return mail_index_set_syscall_error(index, "stat()"); |
a59deefc552f
NFS attribute cache flushing fixes. nfs_flush_attr_cache() takes now
Timo Sirainen <tss@iki.fi>
parents:
6755
diff
changeset
|
538 } |
a59deefc552f
NFS attribute cache flushing fixes. nfs_flush_attr_cache() takes now
Timo Sirainen <tss@iki.fi>
parents:
6755
diff
changeset
|
539 |
4023
b19ccbaa3802
Try to handle ESTALE NFS errors the best way we can.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3912
diff
changeset
|
540 if (fstat(index->fd, &st1) < 0) { |
5689
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
541 if (errno != ESTALE) |
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
542 return mail_index_set_syscall_error(index, "fstat()"); |
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
543 /* deleted/recreated, reopen */ |
6829
dbab5e592577
NFS cache flushing APIs changed and backend implements it a bit differently.
Timo Sirainen <tss@iki.fi>
parents:
6819
diff
changeset
|
544 } else if (st1.st_ino == st2.st_ino && |
dbab5e592577
NFS cache flushing APIs changed and backend implements it a bit differently.
Timo Sirainen <tss@iki.fi>
parents:
6819
diff
changeset
|
545 CMP_DEV_T(st1.st_dev, st2.st_dev)) { |
5689
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
546 /* the same file */ |
2063
21a3e5d08290
mail_index_refresh() - allows forcing a refresh check
Timo Sirainen <tss@iki.fi>
parents:
2051
diff
changeset
|
547 return 1; |
21a3e5d08290
mail_index_refresh() - allows forcing a refresh check
Timo Sirainen <tss@iki.fi>
parents:
2051
diff
changeset
|
548 } |
5689
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
549 |
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
550 /* new file, new locks. the old fd can keep its locks, they don't |
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
551 matter anymore as no-one's going to modify the file. */ |
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
552 mail_index_close_file(index); |
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
553 |
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
554 return mail_index_try_open_only(index); |
2063
21a3e5d08290
mail_index_refresh() - allows forcing a refresh check
Timo Sirainen <tss@iki.fi>
parents:
2051
diff
changeset
|
555 } |
21a3e5d08290
mail_index_refresh() - allows forcing a refresh check
Timo Sirainen <tss@iki.fi>
parents:
2051
diff
changeset
|
556 |
2936
57f975a9b63b
Renamed mail_index_refresh() to mail_index_reopen_if_needed(). Added public
Timo Sirainen <tss@iki.fi>
parents:
2935
diff
changeset
|
557 int mail_index_refresh(struct mail_index *index) |
57f975a9b63b
Renamed mail_index_refresh() to mail_index_reopen_if_needed(). Added public
Timo Sirainen <tss@iki.fi>
parents:
2935
diff
changeset
|
558 { |
57f975a9b63b
Renamed mail_index_refresh() to mail_index_reopen_if_needed(). Added public
Timo Sirainen <tss@iki.fi>
parents:
2935
diff
changeset
|
559 int ret; |
57f975a9b63b
Renamed mail_index_refresh() to mail_index_reopen_if_needed(). Added public
Timo Sirainen <tss@iki.fi>
parents:
2935
diff
changeset
|
560 |
5854 | 561 ret = mail_index_map(index, MAIL_INDEX_SYNC_HANDLER_HEAD); |
2936
57f975a9b63b
Renamed mail_index_refresh() to mail_index_reopen_if_needed(). Added public
Timo Sirainen <tss@iki.fi>
parents:
2935
diff
changeset
|
562 return ret <= 0 ? -1 : 0; |
57f975a9b63b
Renamed mail_index_refresh() to mail_index_reopen_if_needed(). Added public
Timo Sirainen <tss@iki.fi>
parents:
2935
diff
changeset
|
563 } |
57f975a9b63b
Renamed mail_index_refresh() to mail_index_reopen_if_needed(). Added public
Timo Sirainen <tss@iki.fi>
parents:
2935
diff
changeset
|
564 |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
565 struct mail_cache *mail_index_get_cache(struct mail_index *index) |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
566 { |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
567 return index->cache; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
568 } |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
569 |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
570 int mail_index_set_error(struct mail_index *index, const char *fmt, ...) |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
571 { |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
572 va_list va; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
573 |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
574 i_free(index->error); |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
575 |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
576 if (fmt == NULL) |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
577 index->error = NULL; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
578 else { |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
579 va_start(va, fmt); |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
580 index->error = i_strdup_vprintf(fmt, va); |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
581 va_end(va); |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
582 |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
583 i_error("%s", index->error); |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
584 } |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
585 |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
586 return -1; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
587 } |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
588 |
9099
67369ba9f447
maildir: When saving messages, in some race conditions we might have written a duplicate UID.
Timo Sirainen <tss@iki.fi>
parents:
8973
diff
changeset
|
589 bool mail_index_is_in_memory(struct mail_index *index) |
67369ba9f447
maildir: When saving messages, in some race conditions we might have written a duplicate UID.
Timo Sirainen <tss@iki.fi>
parents:
8973
diff
changeset
|
590 { |
67369ba9f447
maildir: When saving messages, in some race conditions we might have written a duplicate UID.
Timo Sirainen <tss@iki.fi>
parents:
8973
diff
changeset
|
591 return MAIL_INDEX_IS_IN_MEMORY(index); |
67369ba9f447
maildir: When saving messages, in some race conditions we might have written a duplicate UID.
Timo Sirainen <tss@iki.fi>
parents:
8973
diff
changeset
|
592 } |
67369ba9f447
maildir: When saving messages, in some race conditions we might have written a duplicate UID.
Timo Sirainen <tss@iki.fi>
parents:
8973
diff
changeset
|
593 |
3833
318c70c1d4ec
Beginnings of fallbacking to in-memory indexes when write fails with "out of
Timo Sirainen <tss@iki.fi>
parents:
3832
diff
changeset
|
594 int mail_index_move_to_memory(struct mail_index *index) |
318c70c1d4ec
Beginnings of fallbacking to in-memory indexes when write fails with "out of
Timo Sirainen <tss@iki.fi>
parents:
3832
diff
changeset
|
595 { |
3911
3a2fe49912f3
Fixed mail_index_move_to_memory() to work better and made it public
Timo Sirainen <tss@iki.fi>
parents:
3879
diff
changeset
|
596 struct mail_index_map *map; |
3a2fe49912f3
Fixed mail_index_move_to_memory() to work better and made it public
Timo Sirainen <tss@iki.fi>
parents:
3879
diff
changeset
|
597 |
4394
0462137fa4ce
mail_index_move_to_memory(): Don't break if the index is already in memory.
Timo Sirainen <tss@iki.fi>
parents:
4312
diff
changeset
|
598 if (MAIL_INDEX_IS_IN_MEMORY(index)) |
5430
c8bb83980ff7
If mail_index_move_to_memory() fails, make sure the future calls to it also
Timo Sirainen <tss@iki.fi>
parents:
5323
diff
changeset
|
599 return index->map == NULL ? -1 : 0; |
4394
0462137fa4ce
mail_index_move_to_memory(): Don't break if the index is already in memory.
Timo Sirainen <tss@iki.fi>
parents:
4312
diff
changeset
|
600 |
8973
f295678cef1e
dbox: Make sure indexes are never moved to memory (in case of out-of-disk space).
Timo Sirainen <tss@iki.fi>
parents:
8960
diff
changeset
|
601 if (index->never_in_memory) |
f295678cef1e
dbox: Make sure indexes are never moved to memory (in case of out-of-disk space).
Timo Sirainen <tss@iki.fi>
parents:
8960
diff
changeset
|
602 return -1; |
f295678cef1e
dbox: Make sure indexes are never moved to memory (in case of out-of-disk space).
Timo Sirainen <tss@iki.fi>
parents:
8960
diff
changeset
|
603 |
4919
d54145736f99
If mail_index_move_to_memory() was called before index file was opened, we
Timo Sirainen <tss@iki.fi>
parents:
4918
diff
changeset
|
604 /* set the index as being into memory */ |
d54145736f99
If mail_index_move_to_memory() was called before index file was opened, we
Timo Sirainen <tss@iki.fi>
parents:
4918
diff
changeset
|
605 i_free_and_null(index->dir); |
d54145736f99
If mail_index_move_to_memory() was called before index file was opened, we
Timo Sirainen <tss@iki.fi>
parents:
4918
diff
changeset
|
606 |
5274
7641e625fbd5
When moving index file to memory, change the filename to be "(in-memory
Timo Sirainen <tss@iki.fi>
parents:
5273
diff
changeset
|
607 i_free(index->filepath); |
7641e625fbd5
When moving index file to memory, change the filename to be "(in-memory
Timo Sirainen <tss@iki.fi>
parents:
5273
diff
changeset
|
608 index->filepath = i_strdup("(in-memory index)"); |
7641e625fbd5
When moving index file to memory, change the filename to be "(in-memory
Timo Sirainen <tss@iki.fi>
parents:
5273
diff
changeset
|
609 |
3912
fc0b638330a4
Added mbox_min_index_size setting.
Timo Sirainen <tss@iki.fi>
parents:
3911
diff
changeset
|
610 if (index->map == NULL) { |
5224 | 611 /* index was never even opened. just mark it as being in |
3912
fc0b638330a4
Added mbox_min_index_size setting.
Timo Sirainen <tss@iki.fi>
parents:
3911
diff
changeset
|
612 memory and let the caller re-open the index. */ |
fc0b638330a4
Added mbox_min_index_size setting.
Timo Sirainen <tss@iki.fi>
parents:
3911
diff
changeset
|
613 i_assert(index->fd == -1); |
fc0b638330a4
Added mbox_min_index_size setting.
Timo Sirainen <tss@iki.fi>
parents:
3911
diff
changeset
|
614 return -1; |
fc0b638330a4
Added mbox_min_index_size setting.
Timo Sirainen <tss@iki.fi>
parents:
3911
diff
changeset
|
615 } |
fc0b638330a4
Added mbox_min_index_size setting.
Timo Sirainen <tss@iki.fi>
parents:
3911
diff
changeset
|
616 |
3911
3a2fe49912f3
Fixed mail_index_move_to_memory() to work better and made it public
Timo Sirainen <tss@iki.fi>
parents:
3879
diff
changeset
|
617 /* move index map to memory */ |
5278
d569caa88a66
If we run out of disk space, move to in-memory indexes.
Timo Sirainen <tss@iki.fi>
parents:
5274
diff
changeset
|
618 if (!MAIL_INDEX_MAP_IS_IN_MEMORY(index->map)) { |
5689
c2362f144f15
Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents:
5686
diff
changeset
|
619 map = mail_index_map_clone(index->map); |
5853
d9f319a9d6e0
mail_index_map now contains pointer to index, so all functions taking map
Timo Sirainen <tss@iki.fi>
parents:
5827
diff
changeset
|
620 mail_index_unmap(&index->map); |
5278
d569caa88a66
If we run out of disk space, move to in-memory indexes.
Timo Sirainen <tss@iki.fi>
parents:
5274
diff
changeset
|
621 index->map = map; |
d569caa88a66
If we run out of disk space, move to in-memory indexes.
Timo Sirainen <tss@iki.fi>
parents:
5274
diff
changeset
|
622 } |
3911
3a2fe49912f3
Fixed mail_index_move_to_memory() to work better and made it public
Timo Sirainen <tss@iki.fi>
parents:
3879
diff
changeset
|
623 |
4053
94b3363165c8
If transaction log opening fails, don't crash when trying to move it to
Timo Sirainen <tss@iki.fi>
parents:
4026
diff
changeset
|
624 if (index->log != NULL) { |
94b3363165c8
If transaction log opening fails, don't crash when trying to move it to
Timo Sirainen <tss@iki.fi>
parents:
4026
diff
changeset
|
625 /* move transaction log 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
|
626 mail_transaction_log_move_to_memory(index->log); |
4053
94b3363165c8
If transaction log opening fails, don't crash when trying to move it to
Timo Sirainen <tss@iki.fi>
parents:
4026
diff
changeset
|
627 } |
3911
3a2fe49912f3
Fixed mail_index_move_to_memory() to work better and made it public
Timo Sirainen <tss@iki.fi>
parents:
3879
diff
changeset
|
628 |
4876
f1d77064884c
Lock handling changes. Everything goes through file-lock API now and there's
Timo Sirainen <tss@iki.fi>
parents:
4795
diff
changeset
|
629 if (index->file_lock != NULL) |
f1d77064884c
Lock handling changes. Everything goes through file-lock API now and there's
Timo Sirainen <tss@iki.fi>
parents:
4795
diff
changeset
|
630 file_lock_free(&index->file_lock); |
f1d77064884c
Lock handling changes. Everything goes through file-lock API now and there's
Timo Sirainen <tss@iki.fi>
parents:
4795
diff
changeset
|
631 |
6022
8da2881df0dc
mail_index_move_to_memory(): Don't log an error if index fd is already closed
Timo Sirainen <tss@iki.fi>
parents:
5976
diff
changeset
|
632 if (index->fd != -1) { |
8da2881df0dc
mail_index_move_to_memory(): Don't log an error if index fd is already closed
Timo Sirainen <tss@iki.fi>
parents:
5976
diff
changeset
|
633 if (close(index->fd) < 0) |
8da2881df0dc
mail_index_move_to_memory(): Don't log an error if index fd is already closed
Timo Sirainen <tss@iki.fi>
parents:
5976
diff
changeset
|
634 mail_index_set_syscall_error(index, "close()"); |
8da2881df0dc
mail_index_move_to_memory(): Don't log an error if index fd is already closed
Timo Sirainen <tss@iki.fi>
parents:
5976
diff
changeset
|
635 index->fd = -1; |
8da2881df0dc
mail_index_move_to_memory(): Don't log an error if index fd is already closed
Timo Sirainen <tss@iki.fi>
parents:
5976
diff
changeset
|
636 } |
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
|
637 return 0; |
3833
318c70c1d4ec
Beginnings of fallbacking to in-memory indexes when write fails with "out of
Timo Sirainen <tss@iki.fi>
parents:
3832
diff
changeset
|
638 } |
318c70c1d4ec
Beginnings of fallbacking to in-memory indexes when write fails with "out of
Timo Sirainen <tss@iki.fi>
parents:
3832
diff
changeset
|
639 |
1945 | 640 void mail_index_mark_corrupted(struct mail_index *index) |
1943 | 641 { |
5820
e59892590a02
Handle losing index file better. Handle fsck better.
Timo Sirainen <tss@iki.fi>
parents:
5819
diff
changeset
|
642 index->indexid = 0; |
1945 | 643 |
5772
002aa9bbfcb2
Removed index->hdr. Use index->map->hdr instead.
Timo Sirainen <tss@iki.fi>
parents:
5714
diff
changeset
|
644 index->map->hdr.flags |= MAIL_INDEX_HDR_FLAG_CORRUPTED; |
5775
98d5e3bd4d13
Handle corruption marking by unlinking dovecot.index file. Removed
Timo Sirainen <tss@iki.fi>
parents:
5773
diff
changeset
|
645 if (unlink(index->filepath) < 0 && errno != ENOENT && errno != ESTALE) |
98d5e3bd4d13
Handle corruption marking by unlinking dovecot.index file. Removed
Timo Sirainen <tss@iki.fi>
parents:
5773
diff
changeset
|
646 mail_index_set_syscall_error(index, "unlink()"); |
1943 | 647 } |
648 | |
9420
c496f137c843
index: Handle better errors where a new file's group can't be changed.
Timo Sirainen <tss@iki.fi>
parents:
9394
diff
changeset
|
649 void mail_index_fchown(struct mail_index *index, int fd, const char *path) |
c496f137c843
index: Handle better errors where a new file's group can't be changed.
Timo Sirainen <tss@iki.fi>
parents:
9394
diff
changeset
|
650 { |
c496f137c843
index: Handle better errors where a new file's group can't be changed.
Timo Sirainen <tss@iki.fi>
parents:
9394
diff
changeset
|
651 mode_t mode; |
c496f137c843
index: Handle better errors where a new file's group can't be changed.
Timo Sirainen <tss@iki.fi>
parents:
9394
diff
changeset
|
652 |
c496f137c843
index: Handle better errors where a new file's group can't be changed.
Timo Sirainen <tss@iki.fi>
parents:
9394
diff
changeset
|
653 if (index->gid == (gid_t)-1) { |
c496f137c843
index: Handle better errors where a new file's group can't be changed.
Timo Sirainen <tss@iki.fi>
parents:
9394
diff
changeset
|
654 /* no gid changing */ |
c496f137c843
index: Handle better errors where a new file's group can't be changed.
Timo Sirainen <tss@iki.fi>
parents:
9394
diff
changeset
|
655 return; |
c496f137c843
index: Handle better errors where a new file's group can't be changed.
Timo Sirainen <tss@iki.fi>
parents:
9394
diff
changeset
|
656 } else if (fchown(fd, (uid_t)-1, index->gid) == 0) { |
c496f137c843
index: Handle better errors where a new file's group can't be changed.
Timo Sirainen <tss@iki.fi>
parents:
9394
diff
changeset
|
657 /* success */ |
c496f137c843
index: Handle better errors where a new file's group can't be changed.
Timo Sirainen <tss@iki.fi>
parents:
9394
diff
changeset
|
658 return; |
c496f137c843
index: Handle better errors where a new file's group can't be changed.
Timo Sirainen <tss@iki.fi>
parents:
9394
diff
changeset
|
659 } if ((index->mode & 0066) == 0) { |
c496f137c843
index: Handle better errors where a new file's group can't be changed.
Timo Sirainen <tss@iki.fi>
parents:
9394
diff
changeset
|
660 /* group doesn't really matter, ignore silently. */ |
c496f137c843
index: Handle better errors where a new file's group can't be changed.
Timo Sirainen <tss@iki.fi>
parents:
9394
diff
changeset
|
661 return; |
c496f137c843
index: Handle better errors where a new file's group can't be changed.
Timo Sirainen <tss@iki.fi>
parents:
9394
diff
changeset
|
662 } if ((index->mode & 0060) == 0) { |
c496f137c843
index: Handle better errors where a new file's group can't be changed.
Timo Sirainen <tss@iki.fi>
parents:
9394
diff
changeset
|
663 /* file access was granted to everyone, except this group. |
c496f137c843
index: Handle better errors where a new file's group can't be changed.
Timo Sirainen <tss@iki.fi>
parents:
9394
diff
changeset
|
664 to make sure we don't expose it to the group, drop the world |
c496f137c843
index: Handle better errors where a new file's group can't be changed.
Timo Sirainen <tss@iki.fi>
parents:
9394
diff
changeset
|
665 permissions too. */ |
c496f137c843
index: Handle better errors where a new file's group can't be changed.
Timo Sirainen <tss@iki.fi>
parents:
9394
diff
changeset
|
666 mail_index_file_set_syscall_error(index, path, "fchown()"); |
c496f137c843
index: Handle better errors where a new file's group can't be changed.
Timo Sirainen <tss@iki.fi>
parents:
9394
diff
changeset
|
667 mode = index->mode & 0600; |
c496f137c843
index: Handle better errors where a new file's group can't be changed.
Timo Sirainen <tss@iki.fi>
parents:
9394
diff
changeset
|
668 } else { |
c496f137c843
index: Handle better errors where a new file's group can't be changed.
Timo Sirainen <tss@iki.fi>
parents:
9394
diff
changeset
|
669 mail_index_file_set_syscall_error(index, path, "fchown()"); |
c496f137c843
index: Handle better errors where a new file's group can't be changed.
Timo Sirainen <tss@iki.fi>
parents:
9394
diff
changeset
|
670 /* continue, but change group permissions to same as |
c496f137c843
index: Handle better errors where a new file's group can't be changed.
Timo Sirainen <tss@iki.fi>
parents:
9394
diff
changeset
|
671 world-permissions were. */ |
c496f137c843
index: Handle better errors where a new file's group can't be changed.
Timo Sirainen <tss@iki.fi>
parents:
9394
diff
changeset
|
672 mode = (index->mode & 0606) | ((index->mode & 06) << 3); |
c496f137c843
index: Handle better errors where a new file's group can't be changed.
Timo Sirainen <tss@iki.fi>
parents:
9394
diff
changeset
|
673 } |
c496f137c843
index: Handle better errors where a new file's group can't be changed.
Timo Sirainen <tss@iki.fi>
parents:
9394
diff
changeset
|
674 if (fchmod(fd, mode) < 0) { |
c496f137c843
index: Handle better errors where a new file's group can't be changed.
Timo Sirainen <tss@iki.fi>
parents:
9394
diff
changeset
|
675 mail_index_file_set_syscall_error(index, path, |
c496f137c843
index: Handle better errors where a new file's group can't be changed.
Timo Sirainen <tss@iki.fi>
parents:
9394
diff
changeset
|
676 "fchmod()"); |
c496f137c843
index: Handle better errors where a new file's group can't be changed.
Timo Sirainen <tss@iki.fi>
parents:
9394
diff
changeset
|
677 } |
c496f137c843
index: Handle better errors where a new file's group can't be changed.
Timo Sirainen <tss@iki.fi>
parents:
9394
diff
changeset
|
678 } |
c496f137c843
index: Handle better errors where a new file's group can't be changed.
Timo Sirainen <tss@iki.fi>
parents:
9394
diff
changeset
|
679 |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
680 int mail_index_set_syscall_error(struct mail_index *index, |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
681 const char *function) |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
682 { |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
683 i_assert(function != NULL); |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
684 |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
685 if (ENOSPACE(errno)) { |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
686 index->nodiskspace = TRUE; |
8973
f295678cef1e
dbox: Make sure indexes are never moved to memory (in case of out-of-disk space).
Timo Sirainen <tss@iki.fi>
parents:
8960
diff
changeset
|
687 if (!index->never_in_memory) |
f295678cef1e
dbox: Make sure indexes are never moved to memory (in case of out-of-disk space).
Timo Sirainen <tss@iki.fi>
parents:
8960
diff
changeset
|
688 return -1; |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
689 } |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
690 |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
691 return mail_index_set_error(index, "%s failed with index file %s: %m", |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
692 function, index->filepath); |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
693 } |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
694 |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
695 int mail_index_file_set_syscall_error(struct mail_index *index, |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
696 const char *filepath, |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
697 const char *function) |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
698 { |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
699 i_assert(filepath != NULL); |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
700 i_assert(function != NULL); |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
701 |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
702 if (ENOSPACE(errno)) { |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
703 index->nodiskspace = TRUE; |
8973
f295678cef1e
dbox: Make sure indexes are never moved to memory (in case of out-of-disk space).
Timo Sirainen <tss@iki.fi>
parents:
8960
diff
changeset
|
704 if (!index->never_in_memory) |
f295678cef1e
dbox: Make sure indexes are never moved to memory (in case of out-of-disk space).
Timo Sirainen <tss@iki.fi>
parents:
8960
diff
changeset
|
705 return -1; |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
706 } |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
707 |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
708 return mail_index_set_error(index, "%s failed with file %s: %m", |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
709 function, filepath); |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
710 } |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
711 |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
712 const char *mail_index_get_error_message(struct mail_index *index) |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
713 { |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
714 return index->error; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
715 } |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
716 |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
717 void mail_index_reset_error(struct mail_index *index) |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
718 { |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
719 if (index->error != NULL) { |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
720 i_free(index->error); |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
721 index->error = NULL; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
722 } |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
723 |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
724 index->nodiskspace = FALSE; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
725 index->index_lock_timeout = FALSE; |
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
726 } |