mail-index-transaction-export.c revision 2454dfa32c93c20a8522c6ed42fe057baaac9f9a
/* Copyright (c) 2003-2017 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "mail-index-private.h"
#include "mail-index-modseq.h"
#include "mail-transaction-log-private.h"
#include "mail-index-transaction-private.h"
struct mail_index_export_context {
struct mail_index_transaction *trans;
};
static void
{
}
struct mail_index_transaction *t)
{
const struct mail_index_flag_update *updates;
struct mail_transaction_flag_update *log_update;
unsigned int i, count;
if (count == 0)
return;
for (i = 0; i < count; i++) {
}
}
static const buffer_t *
{
struct mail_transaction_header_update u;
int state = 0;
i_zero(&u);
if (state == 0) {
state++;
}
} else {
if (state > 0) {
buffer_append(buf, &u, sizeof(u));
state = 0;
}
}
}
return buf;
}
static unsigned int
{
unsigned int i;
for (i = hu->alloc_size; i > 0; i--) {
return i;
}
return 0;
}
unsigned int *hdr_size_r)
{
const struct mail_index_registered_ext *rext;
const struct mail_index_ext *ext;
unsigned int count;
if (t->reset ||
/* new extension */
}
if (!array_is_created(&t->ext_resizes)) {
count = 0;
} else {
}
/* we're resizing the extension. use the resize struct. */
} else {
}
} else {
/* generate a new intro structure */
} else {
}
/* handle increasing header size automatically */
if (array_is_created(&t->ext_hdr_updates) &&
const struct mail_index_transaction_ext_hdr_update *hu;
unsigned int hdr_update_size;
}
}
if (reset_id != 0) {
/* we're going to reset this extension in this transaction */
/* use the existing reset_id */
const struct mail_index_ext *map_ext =
} else {
/* new extension, reset_id defaults to 0 */
}
/* modseq tracking started */
}
}
static void
const struct mail_index_transaction_ext_hdr_update *hdr,
unsigned int ext_hdr_size)
{
struct mail_transaction_ext_hdr_update u;
struct mail_transaction_ext_hdr_update32 u32;
i_zero(&u);
if (!started) {
}
} else {
if (started) {
if (use_32)
else {
buffer_append(buf, &u, sizeof(u));
}
}
}
}
}
static void
{
const struct mail_transaction_ext_intro *resize;
const struct mail_index_transaction_ext_hdr_update *hdrs;
struct mail_transaction_ext_reset ext_reset;
unsigned int resize_count, ext_count = 0;
const struct mail_transaction_ext_reset *reset;
if (!array_is_created(&t->ext_resizes)) {
resize_count = 0;
} else {
if (ext_count < resize_count)
}
if (!array_is_created(&t->ext_reset_ids)) {
reset_id_count = 0;
} else {
}
if (!array_is_created(&t->ext_resets)) {
reset_count = 0;
} else {
if (ext_count < reset_count)
}
if (!array_is_created(&t->ext_hdr_updates)) {
hdrs_count = 0;
} else {
if (ext_count < hdrs_count)
}
if (ext_id < reset_count)
else
ext_reset.new_reset_id = 0;
ext_reset.new_reset_id != 0 ||
if (ext_reset.new_reset_id != 0) {
/* we're going to reset this extension
immediately after the intro */
reset_id = 0;
} else {
}
} else {
hdr_size = 0;
}
if (ext_reset.new_reset_id != 0) {
}
T_BEGIN {
hdr_size);
} T_END;
}
}
}
enum mail_transaction_type type)
{
if (!array_is_created(&t->ext_reset_ids)) {
reset_id_count = 0;
} else {
}
continue;
}
}
static void
{
}
static enum mail_index_fsync_mask
{
const struct mail_index_transaction_keyword_update *updates;
const char *const *keywords;
enum mail_index_fsync_mask change_mask = 0;
unsigned int i, count, keywords_count;
for (i = 0; i < count; i++) {
MODIFY_ADD, keywords[i],
}
MODIFY_REMOVE, keywords[i],
}
}
return change_mask;
}
void mail_index_transaction_export(struct mail_index_transaction *t,
{
enum mail_index_fsync_mask change_mask = 0;
struct mail_index_export_context ctx;
if (t->index_undeleted) {
i_assert(!t->index_deleted);
}
/* send all extension introductions and resizes before appends
to avoid resize overhead as much as possible */
if (t->pre_hdr_changed) {
}
if (t->attribute_updates != NULL) {
/* need to have 32bit alignment */
}
/* append the timestamp and value lengths */
t->attribute_updates_suffix->used);
}
if (array_is_created(&t->appends)) {
}
if (array_is_created(&t->updates)) {
log_append_flag_updates(&ctx, t);
}
if (array_is_created(&t->ext_rec_updates)) {
}
if (array_is_created(&t->ext_rec_atomics)) {
}
if (array_is_created(&t->keyword_updates))
/* keep modseq updates almost last */
if (array_is_created(&t->modseq_updates)) {
}
if (array_is_created(&t->expunges)) {
/* non-external expunges are only requests, ignore them when
checking fsync_mask */
if ((t->flags & MAIL_INDEX_TRANSACTION_FLAG_EXTERNAL) != 0)
}
if (t->post_hdr_changed) {
}
if (t->index_deleted) {
i_assert(!t->index_undeleted);
&null4, 4);
}
(t->flags & MAIL_INDEX_TRANSACTION_FLAG_FSYNC) != 0;
}
static unsigned int
count_modseq_incs_with(struct mail_index_transaction *t,
{
if (!array_is_created(orig_seqs))
return 0;
}
static unsigned int
{
const struct mail_index_transaction_keyword_update *update;
unsigned int count = 0;
}
return count;
}
{
if (new_highest_modseq == 0) {
/* highest-modseq tracking isn't enabled in this transaction
log file. This shouldn't happen with logs created since
v2.2.26+, because initial_modseq is always set. We don't
also bother checking if this transaction itself enables the
highest-modseq tracking, because it's always done as a
standalone transaction in mail_index_modseq_enable(),
which doesn't care about this function. */
i_warning("%s: Requested highest-modseq for transaction, "
"but modseq tracking isn't enabled for the file "
return 0;
}
/* finish everything that can affect highest-modseq */
/* NOTE: keep in sync with mail_transaction_update_modseq() */
/* sorting may change the order of keyword_updates, */
}
if (array_is_created(&t->keyword_updates)) {
}
if (t->attribute_updates != NULL)
/* NOTE: the order of modseq_updates and everything following it
must match mail_index_transaction_export(). */
if (array_is_created(&t->modseq_updates)) {
const struct mail_transaction_modseq_update *mu;
/* mail_index_update_highest_modseq() is handled here also,
as a special case of uid==0. */
if (new_highest_modseq < modseq)
}
}
(t->flags & MAIL_INDEX_TRANSACTION_FLAG_EXTERNAL) != 0)
return new_highest_modseq;
}