Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/lib-index/mail-index-transaction-view.c @ 8192:32aa972895cc HEAD
Transaction view: lookup_ext() crashed if extension was just being added within the transaction.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 11 Sep 2008 23:16:27 +0300 |
parents | cf2c4f3c636f |
children | 413c70b0ae1d |
rev | line source |
---|---|
7086
7ed926ed7aa4
Updated copyright notices to include year 2008.
Timo Sirainen <tss@iki.fi>
parents:
7064
diff
changeset
|
1 /* Copyright (c) 2004-2008 Dovecot authors, see the included COPYING file */ |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
2 |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
3 #include "lib.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:
3195
diff
changeset
|
4 #include "array.h" |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
5 #include "buffer.h" |
4333
8bfdd3928097
mail_index_lookup() and mail_index_lookup_full() returns now 0 if the mail has been expunged within the transaction.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3879
diff
changeset
|
6 #include "seq-range-array.h" |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
7 #include "mail-index-private.h" |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
8 #include "mail-index-view-private.h" |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
9 #include "mail-index-transaction-private.h" |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
10 |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
11 struct mail_index_view_transaction { |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
12 struct mail_index_view view; |
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
|
13 struct mail_index_view_vfuncs *super; |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
14 struct mail_index_transaction *t; |
4528
74212d11b6b5
Transaction view: mail_index_get_header() returns now updated next_uid field
Timo Sirainen <tss@iki.fi>
parents:
4453
diff
changeset
|
15 |
6262
15abc6d262cd
mail_index_ext_get_reset_id() takes now map parameters. Fixed it to work
Timo Sirainen <tss@iki.fi>
parents:
6171
diff
changeset
|
16 struct mail_index_map *lookup_map; |
4528
74212d11b6b5
Transaction view: mail_index_get_header() returns now updated next_uid field
Timo Sirainen <tss@iki.fi>
parents:
4453
diff
changeset
|
17 struct mail_index_header hdr; |
8126
cf2c4f3c636f
mail_index_lookup_ext*() didn't return properly aligned pointers with updated transaction views.
Timo Sirainen <tss@iki.fi>
parents:
8115
diff
changeset
|
18 buffer_t *lookup_return_data; |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
19 }; |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
20 |
6420
a8b515e1a26f
Removed _ prefixes from function names.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
21 static void tview_close(struct mail_index_view *view) |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
22 { |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
23 struct mail_index_view_transaction *tview = |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
24 (struct mail_index_view_transaction *)view; |
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
|
25 struct mail_index_transaction *t = tview->t; |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
26 |
6262
15abc6d262cd
mail_index_ext_get_reset_id() takes now map parameters. Fixed it to work
Timo Sirainen <tss@iki.fi>
parents:
6171
diff
changeset
|
27 if (tview->lookup_map != NULL) |
15abc6d262cd
mail_index_ext_get_reset_id() takes now map parameters. Fixed it to work
Timo Sirainen <tss@iki.fi>
parents:
6171
diff
changeset
|
28 mail_index_unmap(&tview->lookup_map); |
8126
cf2c4f3c636f
mail_index_lookup_ext*() didn't return properly aligned pointers with updated transaction views.
Timo Sirainen <tss@iki.fi>
parents:
8115
diff
changeset
|
29 if (tview->lookup_return_data != NULL) |
cf2c4f3c636f
mail_index_lookup_ext*() didn't return properly aligned pointers with updated transaction views.
Timo Sirainen <tss@iki.fi>
parents:
8115
diff
changeset
|
30 buffer_free(&tview->lookup_return_data); |
6262
15abc6d262cd
mail_index_ext_get_reset_id() takes now map parameters. Fixed it to work
Timo Sirainen <tss@iki.fi>
parents:
6171
diff
changeset
|
31 |
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
|
32 tview->super->close(view); |
85fcdb478608
Beginnings of joining mail-storage API more closely to mail-index, so that
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4451
diff
changeset
|
33 mail_index_transaction_unref(&t); |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
34 } |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
35 |
6420
a8b515e1a26f
Removed _ prefixes from function names.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
36 static uint32_t tview_get_message_count(struct mail_index_view *view) |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
37 { |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
38 struct mail_index_view_transaction *tview = |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
39 (struct mail_index_view_transaction *)view; |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
40 |
5855
fd6ff4d9cab1
Removed view->hdr. Use view->map->hdr directly.
Timo Sirainen <tss@iki.fi>
parents:
5228
diff
changeset
|
41 return view->map->hdr.messages_count + |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
42 (tview->t->last_new_seq == 0 ? 0 : |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
43 tview->t->last_new_seq - tview->t->first_new_seq); |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
44 } |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
45 |
2892
62d53b49110d
Changed mail_index_get_header() to return the header as return value because
Timo Sirainen <tss@iki.fi>
parents:
2884
diff
changeset
|
46 static const struct mail_index_header * |
6420
a8b515e1a26f
Removed _ prefixes from function names.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
47 tview_get_header(struct mail_index_view *view) |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
48 { |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
49 struct mail_index_view_transaction *tview = |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
50 (struct mail_index_view_transaction *)view; |
4528
74212d11b6b5
Transaction view: mail_index_get_header() returns now updated next_uid field
Timo Sirainen <tss@iki.fi>
parents:
4453
diff
changeset
|
51 const struct mail_index_header *hdr; |
6037
d911d943438e
Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents:
6036
diff
changeset
|
52 uint32_t next_uid; |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
53 |
2884
173a0296e81d
Update view's header only after syncing the view. This and other changes fix
Timo Sirainen <tss@iki.fi>
parents:
2853
diff
changeset
|
54 /* FIXME: header counters may not be correct */ |
4528
74212d11b6b5
Transaction view: mail_index_get_header() returns now updated next_uid field
Timo Sirainen <tss@iki.fi>
parents:
4453
diff
changeset
|
55 hdr = tview->super->get_header(view); |
74212d11b6b5
Transaction view: mail_index_get_header() returns now updated next_uid field
Timo Sirainen <tss@iki.fi>
parents:
4453
diff
changeset
|
56 |
6037
d911d943438e
Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents:
6036
diff
changeset
|
57 next_uid = mail_index_transaction_get_next_uid(tview->t); |
d911d943438e
Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents:
6036
diff
changeset
|
58 if (next_uid != hdr->next_uid) { |
d911d943438e
Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents:
6036
diff
changeset
|
59 tview->hdr = *hdr; |
d911d943438e
Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents:
6036
diff
changeset
|
60 tview->hdr.next_uid = next_uid; |
d911d943438e
Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents:
6036
diff
changeset
|
61 hdr = &tview->hdr; |
4528
74212d11b6b5
Transaction view: mail_index_get_header() returns now updated next_uid field
Timo Sirainen <tss@iki.fi>
parents:
4453
diff
changeset
|
62 } |
4529 | 63 return hdr; |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
64 } |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
65 |
6277
5f66277bbe40
mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents:
6275
diff
changeset
|
66 static const struct mail_index_record * |
6420
a8b515e1a26f
Removed _ prefixes from function names.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
67 tview_lookup_full(struct mail_index_view *view, uint32_t seq, |
a8b515e1a26f
Removed _ prefixes from function names.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
68 struct mail_index_map **map_r, bool *expunged_r) |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
69 { |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
70 struct mail_index_view_transaction *tview = |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
71 (struct mail_index_view_transaction *)view; |
6277
5f66277bbe40
mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents:
6275
diff
changeset
|
72 const struct mail_index_record *rec; |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
73 |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
74 if (seq >= tview->t->first_new_seq) { |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
75 /* FIXME: is this right to return index map..? |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
76 it's not there yet. */ |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
77 *map_r = view->index->map; |
6277
5f66277bbe40
mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents:
6275
diff
changeset
|
78 *expunged_r = FALSE; |
5f66277bbe40
mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents:
6275
diff
changeset
|
79 return mail_index_transaction_lookup(tview->t, seq); |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
80 } |
4333
8bfdd3928097
mail_index_lookup() and mail_index_lookup_full() returns now 0 if the mail has been expunged within the transaction.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3879
diff
changeset
|
81 |
6277
5f66277bbe40
mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents:
6275
diff
changeset
|
82 rec = tview->super->lookup_full(view, seq, map_r, expunged_r); |
4333
8bfdd3928097
mail_index_lookup() and mail_index_lookup_full() returns now 0 if the mail has been expunged within the transaction.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3879
diff
changeset
|
83 |
8bfdd3928097
mail_index_lookup() and mail_index_lookup_full() returns now 0 if the mail has been expunged within the transaction.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3879
diff
changeset
|
84 /* if we're expunged within this transaction, return 0 */ |
6277
5f66277bbe40
mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents:
6275
diff
changeset
|
85 if (array_is_created(&tview->t->expunges) && |
5f66277bbe40
mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents:
6275
diff
changeset
|
86 seq_range_exists(&tview->t->expunges, seq)) |
5f66277bbe40
mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents:
6275
diff
changeset
|
87 *expunged_r = TRUE; |
5f66277bbe40
mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents:
6275
diff
changeset
|
88 return rec; |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
89 } |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
90 |
6420
a8b515e1a26f
Removed _ prefixes from function names.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
91 static void |
a8b515e1a26f
Removed _ prefixes from function names.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
92 tview_lookup_uid(struct mail_index_view *view, uint32_t seq, uint32_t *uid_r) |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
93 { |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
94 struct mail_index_view_transaction *tview = |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
95 (struct mail_index_view_transaction *)view; |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
96 |
6275
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
6262
diff
changeset
|
97 if (seq >= tview->t->first_new_seq) |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
98 *uid_r = mail_index_transaction_lookup(tview->t, seq)->uid; |
6275
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
6262
diff
changeset
|
99 else |
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
6262
diff
changeset
|
100 tview->super->lookup_uid(view, seq, uid_r); |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
101 } |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
102 |
6677
90bcf480312d
Renamed mail_index_lookup_uid_range() to mail_index_lookup_seq_range(), made
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
103 static void tview_lookup_seq_range(struct mail_index_view *view, |
6420
a8b515e1a26f
Removed _ prefixes from function names.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
104 uint32_t first_uid, uint32_t last_uid, |
a8b515e1a26f
Removed _ prefixes from function names.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
105 uint32_t *first_seq_r, uint32_t *last_seq_r) |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
106 { |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
107 struct mail_index_view_transaction *tview = |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
108 (struct mail_index_view_transaction *)view; |
6036
5d3a941444f1
mail_index_lookup_uid_range() works now correctly when searching for newly
Timo Sirainen <tss@iki.fi>
parents:
5855
diff
changeset
|
109 const struct mail_index_record *rec; |
5d3a941444f1
mail_index_lookup_uid_range() works now correctly when searching for newly
Timo Sirainen <tss@iki.fi>
parents:
5855
diff
changeset
|
110 uint32_t seq; |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
111 |
6677
90bcf480312d
Renamed mail_index_lookup_uid_range() to mail_index_lookup_seq_range(), made
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
112 tview->super->lookup_seq_range(view, first_uid, last_uid, |
6275
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
6262
diff
changeset
|
113 first_seq_r, last_seq_r); |
6036
5d3a941444f1
mail_index_lookup_uid_range() works now correctly when searching for newly
Timo Sirainen <tss@iki.fi>
parents:
5855
diff
changeset
|
114 if (tview->t->last_new_seq == 0) { |
5d3a941444f1
mail_index_lookup_uid_range() works now correctly when searching for newly
Timo Sirainen <tss@iki.fi>
parents:
5855
diff
changeset
|
115 /* no new messages, the results are final. */ |
6275
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
6262
diff
changeset
|
116 return; |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
117 } |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
118 |
6036
5d3a941444f1
mail_index_lookup_uid_range() works now correctly when searching for newly
Timo Sirainen <tss@iki.fi>
parents:
5855
diff
changeset
|
119 rec = mail_index_transaction_lookup(tview->t, tview->t->first_new_seq); |
5d3a941444f1
mail_index_lookup_uid_range() works now correctly when searching for newly
Timo Sirainen <tss@iki.fi>
parents:
5855
diff
changeset
|
120 if (rec->uid == 0) { |
5d3a941444f1
mail_index_lookup_uid_range() works now correctly when searching for newly
Timo Sirainen <tss@iki.fi>
parents:
5855
diff
changeset
|
121 /* new messages don't have UIDs */ |
6275
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
6262
diff
changeset
|
122 return; |
6036
5d3a941444f1
mail_index_lookup_uid_range() works now correctly when searching for newly
Timo Sirainen <tss@iki.fi>
parents:
5855
diff
changeset
|
123 } |
5d3a941444f1
mail_index_lookup_uid_range() works now correctly when searching for newly
Timo Sirainen <tss@iki.fi>
parents:
5855
diff
changeset
|
124 if (last_uid < rec->uid) { |
5d3a941444f1
mail_index_lookup_uid_range() works now correctly when searching for newly
Timo Sirainen <tss@iki.fi>
parents:
5855
diff
changeset
|
125 /* all wanted messages were existing */ |
6275
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
6262
diff
changeset
|
126 return; |
6036
5d3a941444f1
mail_index_lookup_uid_range() works now correctly when searching for newly
Timo Sirainen <tss@iki.fi>
parents:
5855
diff
changeset
|
127 } |
5d3a941444f1
mail_index_lookup_uid_range() works now correctly when searching for newly
Timo Sirainen <tss@iki.fi>
parents:
5855
diff
changeset
|
128 |
5d3a941444f1
mail_index_lookup_uid_range() works now correctly when searching for newly
Timo Sirainen <tss@iki.fi>
parents:
5855
diff
changeset
|
129 /* at least some of the wanted messages are newly created */ |
7064
046d06f52aa6
mail_index_lookup_seq*() were broken for updated transaction view when
Timo Sirainen <tss@iki.fi>
parents:
6677
diff
changeset
|
130 if (*first_seq_r == 0) { |
046d06f52aa6
mail_index_lookup_seq*() were broken for updated transaction view when
Timo Sirainen <tss@iki.fi>
parents:
6677
diff
changeset
|
131 seq = tview->t->first_new_seq; |
046d06f52aa6
mail_index_lookup_seq*() were broken for updated transaction view when
Timo Sirainen <tss@iki.fi>
parents:
6677
diff
changeset
|
132 for (; seq <= tview->t->last_new_seq; seq++) { |
8115
8ac8713b1386
mail_index_lookup_seq*() could have returned wrong sequences with transaction views.
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
133 rec = mail_index_transaction_lookup(tview->t, seq); |
7064
046d06f52aa6
mail_index_lookup_seq*() were broken for updated transaction view when
Timo Sirainen <tss@iki.fi>
parents:
6677
diff
changeset
|
134 if (first_uid <= rec->uid) |
046d06f52aa6
mail_index_lookup_seq*() were broken for updated transaction view when
Timo Sirainen <tss@iki.fi>
parents:
6677
diff
changeset
|
135 break; |
046d06f52aa6
mail_index_lookup_seq*() were broken for updated transaction view when
Timo Sirainen <tss@iki.fi>
parents:
6677
diff
changeset
|
136 } |
046d06f52aa6
mail_index_lookup_seq*() were broken for updated transaction view when
Timo Sirainen <tss@iki.fi>
parents:
6677
diff
changeset
|
137 if (seq > tview->t->last_new_seq) { |
046d06f52aa6
mail_index_lookup_seq*() were broken for updated transaction view when
Timo Sirainen <tss@iki.fi>
parents:
6677
diff
changeset
|
138 /* no messages in range */ |
046d06f52aa6
mail_index_lookup_seq*() were broken for updated transaction view when
Timo Sirainen <tss@iki.fi>
parents:
6677
diff
changeset
|
139 return; |
046d06f52aa6
mail_index_lookup_seq*() were broken for updated transaction view when
Timo Sirainen <tss@iki.fi>
parents:
6677
diff
changeset
|
140 } |
046d06f52aa6
mail_index_lookup_seq*() were broken for updated transaction view when
Timo Sirainen <tss@iki.fi>
parents:
6677
diff
changeset
|
141 *first_seq_r = seq; |
046d06f52aa6
mail_index_lookup_seq*() were broken for updated transaction view when
Timo Sirainen <tss@iki.fi>
parents:
6677
diff
changeset
|
142 } |
6036
5d3a941444f1
mail_index_lookup_uid_range() works now correctly when searching for newly
Timo Sirainen <tss@iki.fi>
parents:
5855
diff
changeset
|
143 |
5d3a941444f1
mail_index_lookup_uid_range() works now correctly when searching for newly
Timo Sirainen <tss@iki.fi>
parents:
5855
diff
changeset
|
144 seq = tview->t->last_new_seq; |
5d3a941444f1
mail_index_lookup_uid_range() works now correctly when searching for newly
Timo Sirainen <tss@iki.fi>
parents:
5855
diff
changeset
|
145 for (; seq >= tview->t->first_new_seq; seq--) { |
5d3a941444f1
mail_index_lookup_uid_range() works now correctly when searching for newly
Timo Sirainen <tss@iki.fi>
parents:
5855
diff
changeset
|
146 rec = mail_index_transaction_lookup(tview->t, seq); |
5d3a941444f1
mail_index_lookup_uid_range() works now correctly when searching for newly
Timo Sirainen <tss@iki.fi>
parents:
5855
diff
changeset
|
147 if (rec->uid <= last_uid) { |
5d3a941444f1
mail_index_lookup_uid_range() works now correctly when searching for newly
Timo Sirainen <tss@iki.fi>
parents:
5855
diff
changeset
|
148 *last_seq_r = seq; |
5d3a941444f1
mail_index_lookup_uid_range() works now correctly when searching for newly
Timo Sirainen <tss@iki.fi>
parents:
5855
diff
changeset
|
149 break; |
5d3a941444f1
mail_index_lookup_uid_range() works now correctly when searching for newly
Timo Sirainen <tss@iki.fi>
parents:
5855
diff
changeset
|
150 } |
5d3a941444f1
mail_index_lookup_uid_range() works now correctly when searching for newly
Timo Sirainen <tss@iki.fi>
parents:
5855
diff
changeset
|
151 } |
5d3a941444f1
mail_index_lookup_uid_range() works now correctly when searching for newly
Timo Sirainen <tss@iki.fi>
parents:
5855
diff
changeset
|
152 i_assert(seq >= tview->t->first_new_seq); |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
153 } |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
154 |
6420
a8b515e1a26f
Removed _ prefixes from function names.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
155 static void tview_lookup_first(struct mail_index_view *view, |
a8b515e1a26f
Removed _ prefixes from function names.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
156 enum mail_flags flags, uint8_t flags_mask, |
a8b515e1a26f
Removed _ prefixes from function names.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
157 uint32_t *seq_r) |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
158 { |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
159 struct mail_index_view_transaction *tview = |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
160 (struct mail_index_view_transaction *)view; |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
161 const struct mail_index_record *rec; |
3191
0df3f5d71958
Changed many buffers to arrays. Cleans up the code a lot.
Timo Sirainen <tss@iki.fi>
parents:
2918
diff
changeset
|
162 unsigned int append_count; |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
163 uint32_t seq, message_count; |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
164 |
6275
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
6262
diff
changeset
|
165 tview->super->lookup_first(view, flags, flags_mask, seq_r); |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
166 if (*seq_r != 0) |
6275
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
6262
diff
changeset
|
167 return; |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
168 |
3191
0df3f5d71958
Changed many buffers to arrays. Cleans up the code a lot.
Timo Sirainen <tss@iki.fi>
parents:
2918
diff
changeset
|
169 rec = array_get(&tview->t->appends, &append_count); |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
170 seq = tview->t->first_new_seq; |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
171 message_count = tview->t->last_new_seq; |
3191
0df3f5d71958
Changed many buffers to arrays. Cleans up the code a lot.
Timo Sirainen <tss@iki.fi>
parents:
2918
diff
changeset
|
172 i_assert(append_count == message_count - seq + 1); |
0df3f5d71958
Changed many buffers to arrays. Cleans up the code a lot.
Timo Sirainen <tss@iki.fi>
parents:
2918
diff
changeset
|
173 |
2563
5752e5ac88f0
Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents:
2271
diff
changeset
|
174 for (; seq <= message_count; seq++, rec++) { |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
175 if ((rec->flags & flags_mask) == (uint8_t)flags) { |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
176 *seq_r = seq; |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
177 break; |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
178 } |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
179 } |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
180 } |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
181 |
6262
15abc6d262cd
mail_index_ext_get_reset_id() takes now map parameters. Fixed it to work
Timo Sirainen <tss@iki.fi>
parents:
6171
diff
changeset
|
182 static struct mail_index_map * |
15abc6d262cd
mail_index_ext_get_reset_id() takes now map parameters. Fixed it to work
Timo Sirainen <tss@iki.fi>
parents:
6171
diff
changeset
|
183 tview_get_lookup_map(struct mail_index_view_transaction *tview) |
15abc6d262cd
mail_index_ext_get_reset_id() takes now map parameters. Fixed it to work
Timo Sirainen <tss@iki.fi>
parents:
6171
diff
changeset
|
184 { |
15abc6d262cd
mail_index_ext_get_reset_id() takes now map parameters. Fixed it to work
Timo Sirainen <tss@iki.fi>
parents:
6171
diff
changeset
|
185 if (tview->lookup_map == NULL) { |
15abc6d262cd
mail_index_ext_get_reset_id() takes now map parameters. Fixed it to work
Timo Sirainen <tss@iki.fi>
parents:
6171
diff
changeset
|
186 tview->lookup_map = |
15abc6d262cd
mail_index_ext_get_reset_id() takes now map parameters. Fixed it to work
Timo Sirainen <tss@iki.fi>
parents:
6171
diff
changeset
|
187 mail_index_map_clone(tview->view.index->map); |
15abc6d262cd
mail_index_ext_get_reset_id() takes now map parameters. Fixed it to work
Timo Sirainen <tss@iki.fi>
parents:
6171
diff
changeset
|
188 } |
15abc6d262cd
mail_index_ext_get_reset_id() takes now map parameters. Fixed it to work
Timo Sirainen <tss@iki.fi>
parents:
6171
diff
changeset
|
189 return tview->lookup_map; |
15abc6d262cd
mail_index_ext_get_reset_id() takes now map parameters. Fixed it to work
Timo Sirainen <tss@iki.fi>
parents:
6171
diff
changeset
|
190 } |
15abc6d262cd
mail_index_ext_get_reset_id() takes now map parameters. Fixed it to work
Timo Sirainen <tss@iki.fi>
parents:
6171
diff
changeset
|
191 |
8126
cf2c4f3c636f
mail_index_lookup_ext*() didn't return properly aligned pointers with updated transaction views.
Timo Sirainen <tss@iki.fi>
parents:
8115
diff
changeset
|
192 static const void * |
cf2c4f3c636f
mail_index_lookup_ext*() didn't return properly aligned pointers with updated transaction views.
Timo Sirainen <tss@iki.fi>
parents:
8115
diff
changeset
|
193 tview_return_updated_ext(struct mail_index_view_transaction *tview, |
cf2c4f3c636f
mail_index_lookup_ext*() didn't return properly aligned pointers with updated transaction views.
Timo Sirainen <tss@iki.fi>
parents:
8115
diff
changeset
|
194 const void *data, uint32_t ext_id) |
cf2c4f3c636f
mail_index_lookup_ext*() didn't return properly aligned pointers with updated transaction views.
Timo Sirainen <tss@iki.fi>
parents:
8115
diff
changeset
|
195 { |
cf2c4f3c636f
mail_index_lookup_ext*() didn't return properly aligned pointers with updated transaction views.
Timo Sirainen <tss@iki.fi>
parents:
8115
diff
changeset
|
196 const struct mail_index_ext *ext; |
8192
32aa972895cc
Transaction view: lookup_ext() crashed if extension was just being added within the transaction.
Timo Sirainen <tss@iki.fi>
parents:
8126
diff
changeset
|
197 const struct mail_index_registered_ext *rext; |
32aa972895cc
Transaction view: lookup_ext() crashed if extension was just being added within the transaction.
Timo Sirainen <tss@iki.fi>
parents:
8126
diff
changeset
|
198 const struct mail_transaction_ext_intro *intro; |
32aa972895cc
Transaction view: lookup_ext() crashed if extension was just being added within the transaction.
Timo Sirainen <tss@iki.fi>
parents:
8126
diff
changeset
|
199 unsigned int record_align, record_size; |
8126
cf2c4f3c636f
mail_index_lookup_ext*() didn't return properly aligned pointers with updated transaction views.
Timo Sirainen <tss@iki.fi>
parents:
8115
diff
changeset
|
200 uint32_t ext_idx; |
cf2c4f3c636f
mail_index_lookup_ext*() didn't return properly aligned pointers with updated transaction views.
Timo Sirainen <tss@iki.fi>
parents:
8115
diff
changeset
|
201 |
cf2c4f3c636f
mail_index_lookup_ext*() didn't return properly aligned pointers with updated transaction views.
Timo Sirainen <tss@iki.fi>
parents:
8115
diff
changeset
|
202 /* data begins with a 32bit sequence, followed by the actual |
cf2c4f3c636f
mail_index_lookup_ext*() didn't return properly aligned pointers with updated transaction views.
Timo Sirainen <tss@iki.fi>
parents:
8115
diff
changeset
|
203 extension data */ |
cf2c4f3c636f
mail_index_lookup_ext*() didn't return properly aligned pointers with updated transaction views.
Timo Sirainen <tss@iki.fi>
parents:
8115
diff
changeset
|
204 data = CONST_PTR_OFFSET(data, sizeof(uint32_t)); |
cf2c4f3c636f
mail_index_lookup_ext*() didn't return properly aligned pointers with updated transaction views.
Timo Sirainen <tss@iki.fi>
parents:
8115
diff
changeset
|
205 |
8192
32aa972895cc
Transaction view: lookup_ext() crashed if extension was just being added within the transaction.
Timo Sirainen <tss@iki.fi>
parents:
8126
diff
changeset
|
206 if (!mail_index_map_get_ext_idx(tview->lookup_map, ext_id, &ext_idx)) { |
32aa972895cc
Transaction view: lookup_ext() crashed if extension was just being added within the transaction.
Timo Sirainen <tss@iki.fi>
parents:
8126
diff
changeset
|
207 /* we're adding the extension now. */ |
32aa972895cc
Transaction view: lookup_ext() crashed if extension was just being added within the transaction.
Timo Sirainen <tss@iki.fi>
parents:
8126
diff
changeset
|
208 rext = array_idx(&tview->view.index->extensions, ext_id); |
32aa972895cc
Transaction view: lookup_ext() crashed if extension was just being added within the transaction.
Timo Sirainen <tss@iki.fi>
parents:
8126
diff
changeset
|
209 record_align = ext->record_align; |
32aa972895cc
Transaction view: lookup_ext() crashed if extension was just being added within the transaction.
Timo Sirainen <tss@iki.fi>
parents:
8126
diff
changeset
|
210 record_size = ext->record_size; |
32aa972895cc
Transaction view: lookup_ext() crashed if extension was just being added within the transaction.
Timo Sirainen <tss@iki.fi>
parents:
8126
diff
changeset
|
211 } else { |
32aa972895cc
Transaction view: lookup_ext() crashed if extension was just being added within the transaction.
Timo Sirainen <tss@iki.fi>
parents:
8126
diff
changeset
|
212 ext = array_idx(&tview->lookup_map->extensions, ext_idx); |
32aa972895cc
Transaction view: lookup_ext() crashed if extension was just being added within the transaction.
Timo Sirainen <tss@iki.fi>
parents:
8126
diff
changeset
|
213 record_align = ext->record_align; |
32aa972895cc
Transaction view: lookup_ext() crashed if extension was just being added within the transaction.
Timo Sirainen <tss@iki.fi>
parents:
8126
diff
changeset
|
214 record_size = ext->record_size; |
32aa972895cc
Transaction view: lookup_ext() crashed if extension was just being added within the transaction.
Timo Sirainen <tss@iki.fi>
parents:
8126
diff
changeset
|
215 } |
8126
cf2c4f3c636f
mail_index_lookup_ext*() didn't return properly aligned pointers with updated transaction views.
Timo Sirainen <tss@iki.fi>
parents:
8115
diff
changeset
|
216 |
8192
32aa972895cc
Transaction view: lookup_ext() crashed if extension was just being added within the transaction.
Timo Sirainen <tss@iki.fi>
parents:
8126
diff
changeset
|
217 /* see if the extension has been resized within this transaction */ |
32aa972895cc
Transaction view: lookup_ext() crashed if extension was just being added within the transaction.
Timo Sirainen <tss@iki.fi>
parents:
8126
diff
changeset
|
218 if (array_is_created(&tview->t->ext_resizes) && |
32aa972895cc
Transaction view: lookup_ext() crashed if extension was just being added within the transaction.
Timo Sirainen <tss@iki.fi>
parents:
8126
diff
changeset
|
219 ext_id < array_count(&tview->t->ext_resizes)) { |
32aa972895cc
Transaction view: lookup_ext() crashed if extension was just being added within the transaction.
Timo Sirainen <tss@iki.fi>
parents:
8126
diff
changeset
|
220 intro = array_idx(&tview->t->ext_resizes, ext_id); |
32aa972895cc
Transaction view: lookup_ext() crashed if extension was just being added within the transaction.
Timo Sirainen <tss@iki.fi>
parents:
8126
diff
changeset
|
221 if (intro[ext_id].name_size != 0) { |
32aa972895cc
Transaction view: lookup_ext() crashed if extension was just being added within the transaction.
Timo Sirainen <tss@iki.fi>
parents:
8126
diff
changeset
|
222 record_align = intro->record_align; |
32aa972895cc
Transaction view: lookup_ext() crashed if extension was just being added within the transaction.
Timo Sirainen <tss@iki.fi>
parents:
8126
diff
changeset
|
223 record_size = intro->record_size; |
32aa972895cc
Transaction view: lookup_ext() crashed if extension was just being added within the transaction.
Timo Sirainen <tss@iki.fi>
parents:
8126
diff
changeset
|
224 } |
32aa972895cc
Transaction view: lookup_ext() crashed if extension was just being added within the transaction.
Timo Sirainen <tss@iki.fi>
parents:
8126
diff
changeset
|
225 } |
32aa972895cc
Transaction view: lookup_ext() crashed if extension was just being added within the transaction.
Timo Sirainen <tss@iki.fi>
parents:
8126
diff
changeset
|
226 |
8126
cf2c4f3c636f
mail_index_lookup_ext*() didn't return properly aligned pointers with updated transaction views.
Timo Sirainen <tss@iki.fi>
parents:
8115
diff
changeset
|
227 if (ext->record_align <= sizeof(uint32_t)) { |
cf2c4f3c636f
mail_index_lookup_ext*() didn't return properly aligned pointers with updated transaction views.
Timo Sirainen <tss@iki.fi>
parents:
8115
diff
changeset
|
228 /* data is 32bit aligned already */ |
cf2c4f3c636f
mail_index_lookup_ext*() didn't return properly aligned pointers with updated transaction views.
Timo Sirainen <tss@iki.fi>
parents:
8115
diff
changeset
|
229 return data; |
cf2c4f3c636f
mail_index_lookup_ext*() didn't return properly aligned pointers with updated transaction views.
Timo Sirainen <tss@iki.fi>
parents:
8115
diff
changeset
|
230 } else { |
cf2c4f3c636f
mail_index_lookup_ext*() didn't return properly aligned pointers with updated transaction views.
Timo Sirainen <tss@iki.fi>
parents:
8115
diff
changeset
|
231 /* assume we want 64bit alignment - copy the data to |
cf2c4f3c636f
mail_index_lookup_ext*() didn't return properly aligned pointers with updated transaction views.
Timo Sirainen <tss@iki.fi>
parents:
8115
diff
changeset
|
232 temporary buffer and return it */ |
cf2c4f3c636f
mail_index_lookup_ext*() didn't return properly aligned pointers with updated transaction views.
Timo Sirainen <tss@iki.fi>
parents:
8115
diff
changeset
|
233 if (tview->lookup_return_data == NULL) { |
cf2c4f3c636f
mail_index_lookup_ext*() didn't return properly aligned pointers with updated transaction views.
Timo Sirainen <tss@iki.fi>
parents:
8115
diff
changeset
|
234 tview->lookup_return_data = |
cf2c4f3c636f
mail_index_lookup_ext*() didn't return properly aligned pointers with updated transaction views.
Timo Sirainen <tss@iki.fi>
parents:
8115
diff
changeset
|
235 buffer_create_dynamic(default_pool, |
cf2c4f3c636f
mail_index_lookup_ext*() didn't return properly aligned pointers with updated transaction views.
Timo Sirainen <tss@iki.fi>
parents:
8115
diff
changeset
|
236 ext->record_size + 64); |
cf2c4f3c636f
mail_index_lookup_ext*() didn't return properly aligned pointers with updated transaction views.
Timo Sirainen <tss@iki.fi>
parents:
8115
diff
changeset
|
237 } |
cf2c4f3c636f
mail_index_lookup_ext*() didn't return properly aligned pointers with updated transaction views.
Timo Sirainen <tss@iki.fi>
parents:
8115
diff
changeset
|
238 buffer_write(tview->lookup_return_data, |
cf2c4f3c636f
mail_index_lookup_ext*() didn't return properly aligned pointers with updated transaction views.
Timo Sirainen <tss@iki.fi>
parents:
8115
diff
changeset
|
239 0, data, ext->record_size); |
cf2c4f3c636f
mail_index_lookup_ext*() didn't return properly aligned pointers with updated transaction views.
Timo Sirainen <tss@iki.fi>
parents:
8115
diff
changeset
|
240 return tview->lookup_return_data->data; |
cf2c4f3c636f
mail_index_lookup_ext*() didn't return properly aligned pointers with updated transaction views.
Timo Sirainen <tss@iki.fi>
parents:
8115
diff
changeset
|
241 } |
cf2c4f3c636f
mail_index_lookup_ext*() didn't return properly aligned pointers with updated transaction views.
Timo Sirainen <tss@iki.fi>
parents:
8115
diff
changeset
|
242 } |
cf2c4f3c636f
mail_index_lookup_ext*() didn't return properly aligned pointers with updated transaction views.
Timo Sirainen <tss@iki.fi>
parents:
8115
diff
changeset
|
243 |
6277
5f66277bbe40
mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents:
6275
diff
changeset
|
244 static void |
6420
a8b515e1a26f
Removed _ prefixes from function names.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
245 tview_lookup_ext_full(struct mail_index_view *view, uint32_t seq, |
a8b515e1a26f
Removed _ prefixes from function names.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
246 uint32_t ext_id, struct mail_index_map **map_r, |
a8b515e1a26f
Removed _ prefixes from function names.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
247 const void **data_r, bool *expunged_r) |
2563
5752e5ac88f0
Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents:
2271
diff
changeset
|
248 { |
5752e5ac88f0
Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents:
2271
diff
changeset
|
249 struct mail_index_view_transaction *tview = |
5752e5ac88f0
Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents:
2271
diff
changeset
|
250 (struct mail_index_view_transaction *)view; |
4451
1a35d53c18fc
Array API redesigned to work using unions. It now provides type safety
Timo Sirainen <tss@iki.fi>
parents:
4333
diff
changeset
|
251 const ARRAY_TYPE(seq_array) *ext_buf; |
3191
0df3f5d71958
Changed many buffers to arrays. Cleans up the code a lot.
Timo Sirainen <tss@iki.fi>
parents:
2918
diff
changeset
|
252 const void *data; |
0df3f5d71958
Changed many buffers to arrays. Cleans up the code a lot.
Timo Sirainen <tss@iki.fi>
parents:
2918
diff
changeset
|
253 unsigned int idx; |
2563
5752e5ac88f0
Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents:
2271
diff
changeset
|
254 |
3191
0df3f5d71958
Changed many buffers to arrays. Cleans up the code a lot.
Timo Sirainen <tss@iki.fi>
parents:
2918
diff
changeset
|
255 i_assert(ext_id < array_count(&view->index->extensions)); |
0df3f5d71958
Changed many buffers to arrays. Cleans up the code a lot.
Timo Sirainen <tss@iki.fi>
parents:
2918
diff
changeset
|
256 |
6277
5f66277bbe40
mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents:
6275
diff
changeset
|
257 *expunged_r = FALSE; |
5f66277bbe40
mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents:
6275
diff
changeset
|
258 |
3191
0df3f5d71958
Changed many buffers to arrays. Cleans up the code a lot.
Timo Sirainen <tss@iki.fi>
parents:
2918
diff
changeset
|
259 if (array_is_created(&tview->t->ext_rec_updates) && |
0df3f5d71958
Changed many buffers to arrays. Cleans up the code a lot.
Timo Sirainen <tss@iki.fi>
parents:
2918
diff
changeset
|
260 ext_id < array_count(&tview->t->ext_rec_updates)) { |
0df3f5d71958
Changed many buffers to arrays. Cleans up the code a lot.
Timo Sirainen <tss@iki.fi>
parents:
2918
diff
changeset
|
261 /* there are some ext updates in transaction. |
0df3f5d71958
Changed many buffers to arrays. Cleans up the code a lot.
Timo Sirainen <tss@iki.fi>
parents:
2918
diff
changeset
|
262 see if there's any for this sequence. */ |
0df3f5d71958
Changed many buffers to arrays. Cleans up the code a lot.
Timo Sirainen <tss@iki.fi>
parents:
2918
diff
changeset
|
263 ext_buf = array_idx(&tview->t->ext_rec_updates, ext_id); |
0df3f5d71958
Changed many buffers to arrays. Cleans up the code a lot.
Timo Sirainen <tss@iki.fi>
parents:
2918
diff
changeset
|
264 if (array_is_created(ext_buf) && |
0df3f5d71958
Changed many buffers to arrays. Cleans up the code a lot.
Timo Sirainen <tss@iki.fi>
parents:
2918
diff
changeset
|
265 mail_index_seq_array_lookup(ext_buf, seq, &idx)) { |
0df3f5d71958
Changed many buffers to arrays. Cleans up the code a lot.
Timo Sirainen <tss@iki.fi>
parents:
2918
diff
changeset
|
266 data = array_idx(ext_buf, idx); |
6262
15abc6d262cd
mail_index_ext_get_reset_id() takes now map parameters. Fixed it to work
Timo Sirainen <tss@iki.fi>
parents:
6171
diff
changeset
|
267 *map_r = tview_get_lookup_map(tview); |
8126
cf2c4f3c636f
mail_index_lookup_ext*() didn't return properly aligned pointers with updated transaction views.
Timo Sirainen <tss@iki.fi>
parents:
8115
diff
changeset
|
268 *data_r = tview_return_updated_ext(tview, data, |
cf2c4f3c636f
mail_index_lookup_ext*() didn't return properly aligned pointers with updated transaction views.
Timo Sirainen <tss@iki.fi>
parents:
8115
diff
changeset
|
269 ext_id); |
6277
5f66277bbe40
mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents:
6275
diff
changeset
|
270 return; |
3191
0df3f5d71958
Changed many buffers to arrays. Cleans up the code a lot.
Timo Sirainen <tss@iki.fi>
parents:
2918
diff
changeset
|
271 } |
2853
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
272 } |
2563
5752e5ac88f0
Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents:
2271
diff
changeset
|
273 |
3191
0df3f5d71958
Changed many buffers to arrays. Cleans up the code a lot.
Timo Sirainen <tss@iki.fi>
parents:
2918
diff
changeset
|
274 /* not updated, return the existing value */ |
0df3f5d71958
Changed many buffers to arrays. Cleans up the code a lot.
Timo Sirainen <tss@iki.fi>
parents:
2918
diff
changeset
|
275 if (seq < tview->t->first_new_seq) { |
6277
5f66277bbe40
mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents:
6275
diff
changeset
|
276 tview->super->lookup_ext_full(view, seq, ext_id, |
5f66277bbe40
mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents:
6275
diff
changeset
|
277 map_r, data_r, expunged_r); |
5f66277bbe40
mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents:
6275
diff
changeset
|
278 } else { |
5f66277bbe40
mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents:
6275
diff
changeset
|
279 *map_r = view->index->map; |
5f66277bbe40
mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents:
6275
diff
changeset
|
280 *data_r = NULL; |
2563
5752e5ac88f0
Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents:
2271
diff
changeset
|
281 } |
5752e5ac88f0
Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents:
2271
diff
changeset
|
282 } |
5752e5ac88f0
Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents:
2271
diff
changeset
|
283 |
6420
a8b515e1a26f
Removed _ prefixes from function names.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
284 static void tview_get_header_ext(struct mail_index_view *view, |
a8b515e1a26f
Removed _ prefixes from function names.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
285 struct mail_index_map *map, uint32_t ext_id, |
a8b515e1a26f
Removed _ prefixes from function names.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
286 const void **data_r, size_t *data_size_r) |
2853
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
287 { |
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
288 struct mail_index_view_transaction *tview = |
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
289 (struct mail_index_view_transaction *)view; |
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
290 |
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
291 /* FIXME: check updates */ |
6275
913b188f4dd4
Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents:
6262
diff
changeset
|
292 tview->super->get_header_ext(view, map, ext_id, data_r, data_size_r); |
2853
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
293 } |
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
294 |
6420
a8b515e1a26f
Removed _ prefixes from function names.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
295 static bool tview_ext_get_reset_id(struct mail_index_view *view, |
a8b515e1a26f
Removed _ prefixes from function names.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
296 struct mail_index_map *map, |
a8b515e1a26f
Removed _ prefixes from function names.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
297 uint32_t ext_id, uint32_t *reset_id_r) |
6171
635b58fe8287
Added mail_index_ext_get_reset_id() which returns the latest reset_id when
Timo Sirainen <tss@iki.fi>
parents:
6037
diff
changeset
|
298 { |
635b58fe8287
Added mail_index_ext_get_reset_id() which returns the latest reset_id when
Timo Sirainen <tss@iki.fi>
parents:
6037
diff
changeset
|
299 struct mail_index_view_transaction *tview = |
635b58fe8287
Added mail_index_ext_get_reset_id() which returns the latest reset_id when
Timo Sirainen <tss@iki.fi>
parents:
6037
diff
changeset
|
300 (struct mail_index_view_transaction *)view; |
635b58fe8287
Added mail_index_ext_get_reset_id() which returns the latest reset_id when
Timo Sirainen <tss@iki.fi>
parents:
6037
diff
changeset
|
301 const uint32_t *reset_id_p; |
635b58fe8287
Added mail_index_ext_get_reset_id() which returns the latest reset_id when
Timo Sirainen <tss@iki.fi>
parents:
6037
diff
changeset
|
302 |
635b58fe8287
Added mail_index_ext_get_reset_id() which returns the latest reset_id when
Timo Sirainen <tss@iki.fi>
parents:
6037
diff
changeset
|
303 if (array_is_created(&tview->t->ext_reset_ids) && |
6262
15abc6d262cd
mail_index_ext_get_reset_id() takes now map parameters. Fixed it to work
Timo Sirainen <tss@iki.fi>
parents:
6171
diff
changeset
|
304 ext_id < array_count(&tview->t->ext_reset_ids) && |
15abc6d262cd
mail_index_ext_get_reset_id() takes now map parameters. Fixed it to work
Timo Sirainen <tss@iki.fi>
parents:
6171
diff
changeset
|
305 map == tview->lookup_map) { |
6171
635b58fe8287
Added mail_index_ext_get_reset_id() which returns the latest reset_id when
Timo Sirainen <tss@iki.fi>
parents:
6037
diff
changeset
|
306 reset_id_p = array_idx(&tview->t->ext_reset_ids, ext_id); |
635b58fe8287
Added mail_index_ext_get_reset_id() which returns the latest reset_id when
Timo Sirainen <tss@iki.fi>
parents:
6037
diff
changeset
|
307 *reset_id_r = *reset_id_p; |
635b58fe8287
Added mail_index_ext_get_reset_id() which returns the latest reset_id when
Timo Sirainen <tss@iki.fi>
parents:
6037
diff
changeset
|
308 return TRUE; |
635b58fe8287
Added mail_index_ext_get_reset_id() which returns the latest reset_id when
Timo Sirainen <tss@iki.fi>
parents:
6037
diff
changeset
|
309 } |
635b58fe8287
Added mail_index_ext_get_reset_id() which returns the latest reset_id when
Timo Sirainen <tss@iki.fi>
parents:
6037
diff
changeset
|
310 |
6262
15abc6d262cd
mail_index_ext_get_reset_id() takes now map parameters. Fixed it to work
Timo Sirainen <tss@iki.fi>
parents:
6171
diff
changeset
|
311 return tview->super->ext_get_reset_id(view, map, ext_id, reset_id_r); |
6171
635b58fe8287
Added mail_index_ext_get_reset_id() which returns the latest reset_id when
Timo Sirainen <tss@iki.fi>
parents:
6037
diff
changeset
|
312 } |
635b58fe8287
Added mail_index_ext_get_reset_id() which returns the latest reset_id when
Timo Sirainen <tss@iki.fi>
parents:
6037
diff
changeset
|
313 |
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
|
314 static struct mail_index_view_vfuncs trans_view_vfuncs = { |
6420
a8b515e1a26f
Removed _ prefixes from function names.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
315 tview_close, |
a8b515e1a26f
Removed _ prefixes from function names.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
316 tview_get_message_count, |
a8b515e1a26f
Removed _ prefixes from function names.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
317 tview_get_header, |
a8b515e1a26f
Removed _ prefixes from function names.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
318 tview_lookup_full, |
a8b515e1a26f
Removed _ prefixes from function names.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
319 tview_lookup_uid, |
6677
90bcf480312d
Renamed mail_index_lookup_uid_range() to mail_index_lookup_seq_range(), made
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
320 tview_lookup_seq_range, |
6420
a8b515e1a26f
Removed _ prefixes from function names.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
321 tview_lookup_first, |
a8b515e1a26f
Removed _ prefixes from function names.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
322 tview_lookup_ext_full, |
a8b515e1a26f
Removed _ prefixes from function names.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
323 tview_get_header_ext, |
a8b515e1a26f
Removed _ prefixes from function names.
Timo Sirainen <tss@iki.fi>
parents:
6277
diff
changeset
|
324 tview_ext_get_reset_id |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
325 }; |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
326 |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
327 struct mail_index_view * |
2271
15d959d262a4
UIDs for appended messages can now be assigned all at once. Maildir now
Timo Sirainen <tss@iki.fi>
parents:
2240
diff
changeset
|
328 mail_index_transaction_open_updated_view(struct mail_index_transaction *t) |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
329 { |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
330 struct mail_index_view_transaction *tview; |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
331 |
2884
173a0296e81d
Update view's header only after syncing the view. This and other changes fix
Timo Sirainen <tss@iki.fi>
parents:
2853
diff
changeset
|
332 if (t->view->syncing) { |
173a0296e81d
Update view's header only after syncing the view. This and other changes fix
Timo Sirainen <tss@iki.fi>
parents:
2853
diff
changeset
|
333 /* transaction view is being synced. while it's done, it's not |
173a0296e81d
Update view's header only after syncing the view. This and other changes fix
Timo Sirainen <tss@iki.fi>
parents:
2853
diff
changeset
|
334 possible to add new messages, but the view itself might |
173a0296e81d
Update view's header only after syncing the view. This and other changes fix
Timo Sirainen <tss@iki.fi>
parents:
2853
diff
changeset
|
335 change. so we can't make a copy of the view. */ |
173a0296e81d
Update view's header only after syncing the view. This and other changes fix
Timo Sirainen <tss@iki.fi>
parents:
2853
diff
changeset
|
336 mail_index_view_ref(t->view); |
173a0296e81d
Update view's header only after syncing the view. This and other changes fix
Timo Sirainen <tss@iki.fi>
parents:
2853
diff
changeset
|
337 return t->view; |
173a0296e81d
Update view's header only after syncing the view. This and other changes fix
Timo Sirainen <tss@iki.fi>
parents:
2853
diff
changeset
|
338 } |
173a0296e81d
Update view's header only after syncing the view. This and other changes fix
Timo Sirainen <tss@iki.fi>
parents:
2853
diff
changeset
|
339 |
2271
15d959d262a4
UIDs for appended messages can now be assigned all at once. Maildir now
Timo Sirainen <tss@iki.fi>
parents:
2240
diff
changeset
|
340 tview = i_new(struct mail_index_view_transaction, 1); |
15d959d262a4
UIDs for appended messages can now be assigned all at once. Maildir now
Timo Sirainen <tss@iki.fi>
parents:
2240
diff
changeset
|
341 mail_index_view_clone(&tview->view, t->view); |
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
|
342 tview->view.v = trans_view_vfuncs; |
85fcdb478608
Beginnings of joining mail-storage API more closely to mail-index, so that
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4451
diff
changeset
|
343 tview->super = &t->view->v; |
2271
15d959d262a4
UIDs for appended messages can now be assigned all at once. Maildir now
Timo Sirainen <tss@iki.fi>
parents:
2240
diff
changeset
|
344 tview->t = t; |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
345 |
2271
15d959d262a4
UIDs for appended messages can now be assigned all at once. Maildir now
Timo Sirainen <tss@iki.fi>
parents:
2240
diff
changeset
|
346 mail_index_transaction_ref(t); |
15d959d262a4
UIDs for appended messages can now be assigned all at once. Maildir now
Timo Sirainen <tss@iki.fi>
parents:
2240
diff
changeset
|
347 return &tview->view; |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
348 } |