static void index_mail_parse_header_finish(struct index_mail *mail)
{
+ struct mail *_mail = &mail->mail.mail;
const struct index_mail_line *lines;
const unsigned char *header, *data;
const uint8_t *match;
while (match_idx < lines[i].field_idx &&
match_idx < match_count) {
if (HEADER_MATCH_USABLE(mail, match[match_idx]) &&
- mail_cache_field_can_add(mail->trans->cache_trans,
- mail->data.seq,
- match_idx)) {
+ mail_cache_field_can_add(_mail->transaction->cache_trans,
+ _mail->seq, match_idx)) {
/* this header doesn't exist. remember that. */
i_assert((match[match_idx] &
HEADER_MATCH_FLAG_FOUND) == 0);
match_idx++;
}
- if (!mail_cache_field_can_add(mail->trans->cache_trans,
- mail->data.seq,
- lines[i].field_idx)) {
+ if (!mail_cache_field_can_add(_mail->transaction->cache_trans,
+ _mail->seq, lines[i].field_idx)) {
/* header is already cached */
j = i + 1;
continue;
for (; match_idx < match_count; match_idx++) {
if (HEADER_MATCH_USABLE(mail, match[match_idx]) &&
- mail_cache_field_can_add(mail->trans->cache_trans,
- mail->data.seq,
- match_idx)) {
+ mail_cache_field_can_add(_mail->transaction->cache_trans,
+ _mail->seq, match_idx)) {
/* this header doesn't exist. remember that. */
i_assert((match[match_idx] &
HEADER_MATCH_FLAG_FOUND) == 0);
static void index_mail_parse_header_register_all_wanted(struct index_mail *mail)
{
+ struct mail *_mail = &mail->mail.mail;
const struct mail_cache_field *all_cache_fields;
unsigned int i, count;
all_cache_fields =
- mail_cache_register_get_list(mail->mail.mail.box->cache,
+ mail_cache_register_get_list(_mail->box->cache,
pool_datastack_create(), &count);
for (i = 0; i < count; i++) {
if (strncasecmp(all_cache_fields[i].name, "hdr.", 4) != 0)
continue;
- if (!mail_cache_field_want_add(mail->trans->cache_trans,
- mail->data.seq, i))
+ if (!mail_cache_field_want_add(_mail->transaction->cache_trans,
+ _mail->seq, i))
continue;
array_idx_set(&mail->header_match, all_cache_fields[i].idx,
static void index_mail_parse_finish_imap_envelope(struct index_mail *mail)
{
+ struct mail *_mail = &mail->mail.mail;
const unsigned int cache_field_envelope =
mail->ibox->cache_fields[MAIL_CACHE_IMAP_ENVELOPE].idx;
string_t *str;
imap_envelope_write_part_data(mail->data.envelope_data, str);
mail->data.envelope = str_c(str);
- if (mail_cache_field_can_add(mail->trans->cache_trans,
- mail->data.seq, cache_field_envelope)) {
+ if (mail_cache_field_can_add(_mail->transaction->cache_trans,
+ _mail->seq, cache_field_envelope)) {
index_mail_cache_add_idx(mail, cache_field_envelope,
str_data(str), str_len(str));
}
index_mail_get_raw_headers(struct index_mail *mail, const char *field,
const char *const **value_r)
{
+ struct mail *_mail = &mail->mail.mail;
const char *headers[2], *value;
struct mailbox_header_lookup_ctx *headers_ctx;
unsigned char *data;
i_assert(field != NULL);
- field_idx = get_header_field_idx(mail->mail.mail.box, field,
+ field_idx = get_header_field_idx(_mail->box, field,
MAIL_CACHE_DECISION_TEMP);
dest = str_new(mail->data_pool, 128);
- if (mail_cache_lookup_headers(mail->trans->cache_view, dest,
- mail->data.seq, &field_idx, 1) <= 0) {
+ if (mail_cache_lookup_headers(_mail->transaction->cache_view, dest,
+ _mail->seq, &field_idx, 1) <= 0) {
/* not in cache / error - first see if it's already parsed */
p_free(mail->data_pool, dest);
index_mail_header_is_parsed(mail, field_idx) < 0) {
/* parse */
headers[0] = field; headers[1] = NULL;
- headers_ctx = mailbox_header_lookup_init(
- mail->mail.mail.box, headers);
+ headers_ctx = mailbox_header_lookup_init(_mail->box,
+ headers);
ret = index_mail_parse_headers(mail, headers_ctx);
mailbox_header_lookup_unref(&headers_ctx);
if (ret < 0)
}
dest = str_new(mail->data_pool, 256);
- if (mail_cache_lookup_headers(mail->trans->cache_view, dest,
- mail->data.seq, headers->idx,
+ if (mail_cache_lookup_headers(_mail->transaction->cache_view, dest,
+ _mail->seq, headers->idx,
headers->count) > 0) {
mail->mail.stats_cache_hit_count++;
if (mail->data.filter_stream != NULL)
/* not in cache / error */
p_free(mail->data_pool, dest);
- if (mail_get_stream(&mail->mail.mail, NULL, NULL, &input) < 0)
+ if (mail_get_stream(_mail, NULL, NULL, &input) < 0)
return -1;
if (mail->data.filter_stream != NULL)
{
int ret;
- ret = mail_cache_lookup_field(mail->trans->cache_view, buf,
- mail->data.seq, field_idx);
+ ret = mail_cache_lookup_field(mail->mail.mail.transaction->cache_view,
+ buf, mail->data.seq, field_idx);
if (ret > 0)
mail->mail.stats_cache_hit_count++;
return ret;
static struct message_part *get_unserialized_parts(struct index_mail *mail)
{
- unsigned int field_idx =
+ const unsigned int field_idx =
mail->ibox->cache_fields[MAIL_CACHE_MESSAGE_PARTS].idx;
struct message_part *parts;
buffer_t *part_buf;
enum index_cache_field field,
void *data, size_t data_size)
{
- unsigned int field_idx = mail->ibox->cache_fields[field].idx;
+ const unsigned int field_idx = mail->ibox->cache_fields[field].idx;
buffer_t buf;
int ret;
void index_mail_cache_add_idx(struct index_mail *mail, unsigned int field_idx,
const void *data, size_t data_size)
{
- const struct mail_storage_settings *set =
- mail->mail.mail.box->storage->set;
+ struct mail *_mail = &mail->mail.mail;
+ const struct mail_storage_settings *set = _mail->box->storage->set;
const struct mail_index_header *hdr;
if (set->mail_cache_min_mail_count > 0) {
/* First check if we've configured caching not to be used with
low enough message count. */
- hdr = mail_index_get_header(mail->mail.mail.box->view);
+ hdr = mail_index_get_header(_mail->box->view);
if (hdr->messages_count < set->mail_cache_min_mail_count)
return;
}
if (!mail->data.no_caching &&
mail->data.dont_cache_field_idx != field_idx) {
- mail_cache_add(mail->trans->cache_trans, mail->data.seq,
+ mail_cache_add(_mail->transaction->cache_trans, _mail->seq,
field_idx, data, data_size);
}
}
static bool want_plain_bodystructure_cached(struct index_mail *mail)
{
+ const unsigned int cache_field_body =
+ mail->ibox->cache_fields[MAIL_CACHE_IMAP_BODY].idx;
+ const unsigned int cache_field_bodystructure =
+ mail->ibox->cache_fields[MAIL_CACHE_IMAP_BODYSTRUCTURE].idx;
+ struct mail *_mail = &mail->mail.mail;
+
if ((mail->wanted_fields & (MAIL_FETCH_IMAP_BODY |
MAIL_FETCH_IMAP_BODYSTRUCTURE)) != 0)
return TRUE;
- if (mail_cache_field_want_add(mail->trans->cache_trans, mail->data.seq,
- mail->ibox->cache_fields[MAIL_CACHE_IMAP_BODY].idx))
+ if (mail_cache_field_want_add(_mail->transaction->cache_trans,
+ _mail->seq, cache_field_body))
return TRUE;
- if (mail_cache_field_want_add(mail->trans->cache_trans, mail->data.seq,
- mail->ibox->cache_fields[MAIL_CACHE_IMAP_BODYSTRUCTURE].idx))
+ if (mail_cache_field_want_add(_mail->transaction->cache_trans,
+ _mail->seq, cache_field_bodystructure))
return TRUE;
return FALSE;
}
static void index_mail_body_parsed_cache_flags(struct index_mail *mail)
{
+ struct mail *_mail = &mail->mail.mail;
struct index_mail_data *data = &mail->data;
unsigned int cache_flags_idx;
uint32_t cache_flags = data->cache_flags;
bool want_cached;
cache_flags_idx = mail->ibox->cache_fields[MAIL_CACHE_FLAGS].idx;
- want_cached = mail_cache_field_want_add(mail->trans->cache_trans,
- data->seq, cache_flags_idx);
+ want_cached = mail_cache_field_want_add(_mail->transaction->cache_trans,
+ _mail->seq, cache_flags_idx);
if (data->parsed_bodystructure &&
imap_bodystructure_is_plain_7bit(data->parts) &&
MAIL_CACHE_FLAG_HAS_NULS |
MAIL_CACHE_FLAG_HAS_NO_NULS);
if ((data->parts->flags & MESSAGE_PART_FLAG_HAS_NULS) != 0) {
- mail->mail.mail.has_nuls = TRUE;
- mail->mail.mail.has_no_nuls = FALSE;
+ _mail->has_nuls = TRUE;
+ _mail->has_no_nuls = FALSE;
cache_flags |= MAIL_CACHE_FLAG_HAS_NULS;
} else {
- mail->mail.mail.has_nuls = FALSE;
- mail->mail.mail.has_no_nuls = TRUE;
+ _mail->has_nuls = FALSE;
+ _mail->has_no_nuls = TRUE;
cache_flags |= MAIL_CACHE_FLAG_HAS_NO_NULS;
}
static void index_mail_body_parsed_cache_message_parts(struct index_mail *mail)
{
+ struct mail *_mail = &mail->mail.mail;
struct index_mail_data *data = &mail->data;
- unsigned int cache_field =
+ const unsigned int cache_field =
mail->ibox->cache_fields[MAIL_CACHE_MESSAGE_PARTS].idx;
enum mail_cache_decision_type decision;
buffer_t *buffer;
if (data->messageparts_saved_to_cache ||
- mail_cache_field_exists(mail->trans->cache_view, mail->data.seq,
+ mail_cache_field_exists(_mail->transaction->cache_view, _mail->seq,
cache_field) != 0) {
/* already cached */
return;
}
- decision = mail_cache_field_get_decision(mail->mail.mail.box->cache,
+ decision = mail_cache_field_get_decision(_mail->box->cache,
cache_field);
if (decision == (MAIL_CACHE_DECISION_NO | MAIL_CACHE_DECISION_FORCED)) {
/* we never want it cached */
index_mail_body_parsed_cache_bodystructure(struct index_mail *mail,
enum index_cache_field field)
{
+ struct mail *_mail = &mail->mail.mail;
struct index_mail_data *data = &mail->data;
- unsigned int cache_field_parts =
+ const unsigned int cache_field_parts =
mail->ibox->cache_fields[MAIL_CACHE_MESSAGE_PARTS].idx;
- unsigned int cache_field_body =
+ const unsigned int cache_field_body =
mail->ibox->cache_fields[MAIL_CACHE_IMAP_BODY].idx;
- unsigned int cache_field_bodystructure =
+ const unsigned int cache_field_bodystructure =
mail->ibox->cache_fields[MAIL_CACHE_IMAP_BODYSTRUCTURE].idx;
enum mail_cache_decision_type dec;
string_t *str;
if ((data->cache_flags & MAIL_CACHE_FLAG_TEXT_PLAIN_7BIT_ASCII) != 0) {
if (data->messageparts_saved_to_cache ||
- mail_cache_field_exists(mail->trans->cache_view, data->seq,
- cache_field_parts) > 0) {
+ mail_cache_field_exists(_mail->transaction->cache_view,
+ _mail->seq, cache_field_parts) > 0) {
/* cached it as flag + message_parts */
plain_bodystructure = TRUE;
}
else if (field == MAIL_CACHE_IMAP_BODYSTRUCTURE ||
(mail->wanted_fields & MAIL_FETCH_IMAP_BODYSTRUCTURE) != 0) {
cache_bodystructure =
- mail_cache_field_can_add(mail->trans->cache_trans,
- data->seq, cache_field_bodystructure);
+ mail_cache_field_can_add(_mail->transaction->cache_trans,
+ _mail->seq, cache_field_bodystructure);
} else {
cache_bodystructure =
- mail_cache_field_want_add(mail->trans->cache_trans,
- data->seq, cache_field_bodystructure);
+ mail_cache_field_want_add(_mail->transaction->cache_trans,
+ _mail->seq, cache_field_bodystructure);
}
if (cache_bodystructure) {
str = str_new(mail->data_pool, 128);
bodystructure_cached = TRUE;
} else {
bodystructure_cached =
- mail_cache_field_exists(mail->trans->cache_view,
- data->seq, cache_field_bodystructure) > 0;
+ mail_cache_field_exists(_mail->transaction->cache_view,
+ _mail->seq, cache_field_bodystructure) > 0;
}
/* normally don't cache both BODY and BODYSTRUCTURE, but do it
if BODY is forced to be cached */
- dec = mail_cache_field_get_decision(mail->mail.mail.box->cache,
+ dec = mail_cache_field_get_decision(_mail->box->cache,
cache_field_body);
if (plain_bodystructure ||
(bodystructure_cached &&
cache_body = FALSE;
else if (field == MAIL_CACHE_IMAP_BODY) {
cache_body =
- mail_cache_field_can_add(mail->trans->cache_trans,
- data->seq, cache_field_body);
+ mail_cache_field_can_add(_mail->transaction->cache_trans,
+ _mail->seq, cache_field_body);
} else {
cache_body =
- mail_cache_field_want_add(mail->trans->cache_trans,
- data->seq, cache_field_body);
+ mail_cache_field_want_add(_mail->transaction->cache_trans,
+ _mail->seq, cache_field_body);
}
if (cache_body) {
static bool
index_mail_want_cache(struct index_mail *mail, enum index_cache_field field)
{
+ struct mail *_mail = &mail->mail.mail;
enum mail_fetch_field fetch_field;
unsigned int cache_field;
cache_field = mail->ibox->cache_fields[field].idx;
if ((mail->data.cache_fetch_fields & fetch_field) != 0) {
- return mail_cache_field_can_add(mail->trans->cache_trans,
- mail->data.seq, cache_field);
+ return mail_cache_field_can_add(_mail->transaction->cache_trans,
+ _mail->seq, cache_field);
} else {
- return mail_cache_field_want_add(mail->trans->cache_trans,
- mail->data.seq, cache_field);
+ return mail_cache_field_want_add(_mail->transaction->cache_trans,
+ _mail->seq, cache_field);
}
}
enum index_mail_access_part index_mail_get_access_part(struct index_mail *mail)
{
- struct mail_cache_field *cache_fields = mail->ibox->cache_fields;
+ struct mail *_mail = &mail->mail.mail;
+ const struct mail_cache_field *cache_fields = mail->ibox->cache_fields;
if ((mail->data.access_part & (READ_HDR | PARSE_HDR)) != 0 &&
(mail->data.access_part & (READ_BODY | PARSE_BODY)) != 0)
/* lazy virtual size access check */
if ((mail->wanted_fields & MAIL_FETCH_VIRTUAL_SIZE) != 0) {
- unsigned int cache_field =
+ const unsigned int cache_field =
cache_fields[MAIL_CACHE_VIRTUAL_FULL_SIZE].idx;
- if (mail_cache_field_exists(mail->trans->cache_view,
- mail->mail.mail.seq,
- cache_field) <= 0)
+ if (mail_cache_field_exists(_mail->transaction->cache_view,
+ _mail->seq, cache_field) <= 0)
mail->data.access_part |= READ_HDR | READ_BODY;
}
return mail->data.access_part;
{
struct index_mail *mail = (struct index_mail *)_mail;
struct index_mail_data *data = &mail->data;
- struct mail_cache_field *cache_fields = mail->ibox->cache_fields;
+ const struct mail_cache_field *cache_fields = mail->ibox->cache_fields;
string_t *str;
switch (field) {
case MAIL_FETCH_IMAP_BODY: {
- unsigned int body_cache_field =
+ const unsigned int body_cache_field =
cache_fields[MAIL_CACHE_IMAP_BODY].idx;
- unsigned int bodystructure_cache_field =
+ const unsigned int bodystructure_cache_field =
cache_fields[MAIL_CACHE_IMAP_BODYSTRUCTURE].idx;
if (data->body != NULL) {
return 0;
}
case MAIL_FETCH_IMAP_BODYSTRUCTURE: {
- unsigned int bodystructure_cache_field =
+ const unsigned int bodystructure_cache_field =
cache_fields[MAIL_CACHE_IMAP_BODYSTRUCTURE].idx;
if (data->bodystructure != NULL) {
}
void index_mail_init(struct index_mail *mail,
- struct mailbox_transaction_context *_t,
+ struct mailbox_transaction_context *t,
enum mail_fetch_field wanted_fields,
struct mailbox_header_lookup_ctx *_wanted_headers)
{
- struct index_transaction_context *t =
- (struct index_transaction_context *)_t;
struct index_header_lookup_ctx *wanted_headers =
(struct index_header_lookup_ctx *)_wanted_headers;
const struct mail_index_header *hdr;
array_create(&mail->mail.module_contexts, mail->mail.pool,
sizeof(void *), 5);
- mail->mail.v = *_t->box->mail_vfuncs;
- mail->mail.mail.box = _t->box;
- mail->mail.mail.transaction = &t->mailbox_ctx;
+ mail->mail.v = *t->box->mail_vfuncs;
+ mail->mail.mail.box = t->box;
+ mail->mail.mail.transaction = t;
mail->mail.wanted_fields = wanted_fields;
mail->mail.wanted_headers = _wanted_headers;
- hdr = mail_index_get_header(_t->box->view);
+ hdr = mail_index_get_header(t->box->view);
mail->uid_validity = hdr->uid_validity;
t->mail_ref_count++;
mail->data_pool = pool_alloconly_create("index_mail", 16384);
- mail->ibox = INDEX_STORAGE_CONTEXT(_t->box);
- mail->trans = t;
+ mail->ibox = INDEX_STORAGE_CONTEXT(t->box);
mail->wanted_fields = wanted_fields;
if (wanted_headers != NULL) {
mail->wanted_headers = wanted_headers;
static void check_envelope(struct index_mail *mail)
{
- unsigned int cache_field_envelope =
+ struct mail *_mail = &mail->mail.mail;
+ const unsigned int cache_field_envelope =
mail->ibox->cache_fields[MAIL_CACHE_IMAP_ENVELOPE].idx;
unsigned int cache_field_hdr;
}
/* if "imap.envelope" is cached, that's all we need */
- if (mail_cache_field_exists(mail->trans->cache_view,
- mail->mail.mail.seq,
- cache_field_envelope) > 0)
+ if (mail_cache_field_exists(_mail->transaction->cache_view,
+ _mail->seq, cache_field_envelope) > 0)
return;
/* don't waste time doing full checks for all required
headers. assume that if we have "hdr.message-id" cached,
we don't need to parse the header. */
- cache_field_hdr = mail_cache_register_lookup(mail->mail.mail.box->cache,
+ cache_field_hdr = mail_cache_register_lookup(_mail->box->cache,
"hdr.message-id");
if (cache_field_hdr == (unsigned int)-1 ||
- mail_cache_field_exists(mail->trans->cache_view,
- mail->mail.mail.seq,
- cache_field_hdr) <= 0)
+ mail_cache_field_exists(_mail->transaction->cache_view,
+ _mail->seq, cache_field_hdr) <= 0)
mail->data.access_part |= PARSE_HDR;
mail->data.save_envelope = TRUE;
}
{
struct index_mail *mail = (struct index_mail *)_mail;
struct index_mail_data *data = &mail->data;
- struct mail_cache_field *cache_fields = mail->ibox->cache_fields;
- struct mail_cache_view *cache_view = mail->trans->cache_view;
+ const struct mail_cache_field *cache_fields = mail->ibox->cache_fields;
+ struct mail_cache_view *cache_view = _mail->transaction->cache_view;
const struct mail_index_header *hdr;
struct istream *input;
/* see if wanted_fields can tell us if we need to read/parse
header/body */
if ((mail->wanted_fields & MAIL_FETCH_MESSAGE_PARTS) != 0) {
- unsigned int cache_field =
+ const unsigned int cache_field =
cache_fields[MAIL_CACHE_MESSAGE_PARTS].idx;
if (mail_cache_field_exists(cache_view, seq,
if ((mail->wanted_fields & MAIL_FETCH_IMAP_BODY) != 0 &&
(data->cache_flags & MAIL_CACHE_FLAG_TEXT_PLAIN_7BIT_ASCII) == 0) {
/* we need either imap.body or imap.bodystructure */
- unsigned int cache_field1 =
+ const unsigned int cache_field1 =
cache_fields[MAIL_CACHE_IMAP_BODY].idx;
- unsigned int cache_field2 =
+ const unsigned int cache_field2 =
cache_fields[MAIL_CACHE_IMAP_BODYSTRUCTURE].idx;
if (mail_cache_field_exists(cache_view,
if ((mail->wanted_fields & MAIL_FETCH_IMAP_BODYSTRUCTURE) != 0 &&
(data->cache_flags & MAIL_CACHE_FLAG_TEXT_PLAIN_7BIT_ASCII) == 0) {
- unsigned int cache_field =
+ const unsigned int cache_field =
cache_fields[MAIL_CACHE_IMAP_BODYSTRUCTURE].idx;
if (mail_cache_field_exists(cache_view, seq,
}
if ((mail->wanted_fields & MAIL_FETCH_DATE) != 0) {
- unsigned int cache_field =
+ const unsigned int cache_field =
cache_fields[MAIL_CACHE_SENT_DATE].idx;
if (mail_cache_field_exists(cache_view, seq,
mail->mail.v.close(_mail);
- i_assert(mail->trans->mail_ref_count > 0);
- mail->trans->mail_ref_count--;
+ i_assert(_mail->transaction->mail_ref_count > 0);
+ _mail->transaction->mail_ref_count--;
if (mail->header_data != NULL)
buffer_free(&mail->header_data);
}
/* make sure we don't cache invalid values */
- mail_cache_transaction_reset(imail->trans->cache_trans);
+ mail_cache_transaction_reset(mail->transaction->cache_trans);
imail->data.no_caching = TRUE;
imail->data.forced_no_caching = TRUE;
mail_cache_set_corrupted(mail->box->cache,
#include "index-storage.h"
#include "index-mail.h"
-static void index_transaction_free(struct index_transaction_context *t)
+static void index_transaction_free(struct mailbox_transaction_context *t)
{
mail_cache_view_close(t->cache_view);
- mail_index_view_close(&t->mailbox_ctx.view);
- array_free(&t->mailbox_ctx.module_contexts);
+ mail_index_view_close(&t->view);
+ array_free(&t->module_contexts);
i_free(t);
}
index_transaction_index_commit(struct mail_index_transaction *index_trans,
struct mail_index_transaction_commit_result *result_r)
{
- struct index_transaction_context *it =
+ struct mailbox_transaction_context *t =
MAIL_STORAGE_CONTEXT(index_trans);
- struct mailbox_transaction_context *t = &it->mailbox_ctx;
struct index_mailbox_context *ibox = INDEX_STORAGE_CONTEXT(t->box);
int ret = 0;
}
}
- i_assert(it->mail_ref_count == 0);
+ i_assert(t->mail_ref_count == 0);
if (ret < 0)
- it->super.rollback(index_trans);
+ t->super.rollback(index_trans);
else {
- if (it->super.commit(index_trans, result_r) < 0) {
+ if (t->super.commit(index_trans, result_r) < 0) {
mail_storage_set_index_error(t->box);
ret = -1;
}
if (t->save_ctx != NULL)
ibox->save_commit_post(t->save_ctx, result_r);
- index_transaction_free(it);
+ index_transaction_free(t);
return ret;
}
-static void index_transaction_index_rollback(struct mail_index_transaction *t)
+static void
+index_transaction_index_rollback(struct mail_index_transaction *index_trans)
{
- struct index_transaction_context *it = MAIL_STORAGE_CONTEXT(t);
+ struct mailbox_transaction_context *t =
+ MAIL_STORAGE_CONTEXT(index_trans);
struct index_mailbox_context *ibox =
- INDEX_STORAGE_CONTEXT(it->mailbox_ctx.box);
+ INDEX_STORAGE_CONTEXT(t->box);
- if (it->mailbox_ctx.save_ctx != NULL)
- ibox->save_rollback(it->mailbox_ctx.save_ctx);
+ if (t->save_ctx != NULL)
+ ibox->save_rollback(t->save_ctx);
- i_assert(it->mail_ref_count == 0);
- it->super.rollback(t);
- index_transaction_free(it);
+ i_assert(t->mail_ref_count == 0);
+ t->super.rollback(index_trans);
+ index_transaction_free(t);
}
-void index_transaction_init(struct index_transaction_context *it,
+void index_transaction_init(struct mailbox_transaction_context *t,
struct mailbox *box,
enum mailbox_transaction_flags flags)
{
- struct mailbox_transaction_context *t = &it->mailbox_ctx;
enum mail_index_transaction_flags trans_flags;
i_assert(box->opened);
array_create(&t->module_contexts, default_pool,
sizeof(void *), 5);
- it->cache_view = mail_cache_view_open(box->cache, t->view);
- it->cache_trans = mail_cache_get_transaction(it->cache_view, t->itrans);
+ t->cache_view = mail_cache_view_open(box->cache, t->view);
+ t->cache_trans = mail_cache_get_transaction(t->cache_view, t->itrans);
/* set up after mail_cache_get_transaction(), so that we'll still
have the cache_trans available in _index_commit() */
- it->super = t->itrans->v;
+ t->super = t->itrans->v;
t->itrans->v.commit = index_transaction_index_commit;
t->itrans->v.rollback = index_transaction_index_rollback;
- MODULE_CONTEXT_SET(t->itrans, mail_storage_mail_index_module, it);
+ MODULE_CONTEXT_SET(t->itrans, mail_storage_mail_index_module, t);
}
struct mailbox_transaction_context *
index_transaction_begin(struct mailbox *box,
enum mailbox_transaction_flags flags)
{
- struct index_transaction_context *it;
+ struct mailbox_transaction_context *t;
- it = i_new(struct index_transaction_context, 1);
- index_transaction_init(it, box, flags);
- return &it->mailbox_ctx;
+ t = i_new(struct mailbox_transaction_context, 1);
+ index_transaction_init(t, box, flags);
+ return t;
}
int index_transaction_commit(struct mailbox_transaction_context *t,