mail-index-sync-update.c revision c5794838af9995f50bfecb06a3cd4f9a0ac77858
45d862b9c655542aa44c02958011065f6994f512Trond Norbye/* Copyright (c) 2004-2009 Dovecot authors, see the included COPYING file */
45d862b9c655542aa44c02958011065f6994f512Trond Norbye/* If we have less than this many bytes to sync from log file, don't bother
45d862b9c655542aa44c02958011065f6994f512Trond Norbye reading the main index */
45d862b9c655542aa44c02958011065f6994f512Trond Norbye#define MAIL_INDEX_SYNC_MIN_READ_INDEX_SIZE 2048
45d862b9c655542aa44c02958011065f6994f512Trond Norbyemail_index_sync_update_log_offset(struct mail_index_sync_map_ctx *ctx,
45d862b9c655542aa44c02958011065f6994f512Trond Norbye mail_transaction_log_view_get_prev_pos(ctx->view->log_view,
45d862b9c655542aa44c02958011065f6994f512Trond Norbye /* handling lost changes in view syncing */
45d862b9c655542aa44c02958011065f6994f512Trond Norbye if (prev_offset == ctx->ext_intro_end_offset &&
45d862b9c655542aa44c02958011065f6994f512Trond Norbye /* previous transaction was an extension introduction.
45d862b9c655542aa44c02958011065f6994f512Trond Norbye we probably came here from
45d862b9c655542aa44c02958011065f6994f512Trond Norbye mail_index_sync_ext_reset(). if there are any more
45d862b9c655542aa44c02958011065f6994f512Trond Norbye views which want to continue syncing it needs the
45d862b9c655542aa44c02958011065f6994f512Trond Norbye intro. so back up a bit more.
45d862b9c655542aa44c02958011065f6994f512Trond Norbye don't do this in case the last transaction in the
45d862b9c655542aa44c02958011065f6994f512Trond Norbye log is the extension intro, so we don't keep trying
45d862b9c655542aa44c02958011065f6994f512Trond Norbye to sync it over and over again. */
45d862b9c655542aa44c02958011065f6994f512Trond Norbye i_assert(ctx->view->index->log->head->hdr.file_seq == prev_seq);
45d862b9c655542aa44c02958011065f6994f512Trond Norbyestatic void mail_index_sync_replace_map(struct mail_index_sync_map_ctx *ctx,
45d862b9c655542aa44c02958011065f6994f512Trond Norbye mail_index_sync_update_log_offset(ctx, view->map, FALSE);
45d862b9c655542aa44c02958011065f6994f512Trond Norbye mail_index_modseq_sync_map_replaced(ctx->modseq_ctx);
45d862b9c655542aa44c02958011065f6994f512Trond Norbyemail_index_sync_move_to_private_memory(struct mail_index_sync_map_ctx *ctx)
a937449043f1e649320ccb609d9d1de16f6a9208Knut Anders Hatlen if (!MAIL_INDEX_MAP_IS_IN_MEMORY(ctx->view->map))
654c8ccb7fb16112a271048b7ee2d6f46cd746d6Trond Norbye mail_index_modseq_sync_map_replaced(ctx->modseq_ctx);
654c8ccb7fb16112a271048b7ee2d6f46cd746d6Trond Norbyemail_index_sync_get_atomic_map(struct mail_index_sync_map_ctx *ctx)
654c8ccb7fb16112a271048b7ee2d6f46cd746d6Trond Norbye mail_index_record_map_move_to_private(ctx->view->map);
654c8ccb7fb16112a271048b7ee2d6f46cd746d6Trond Norbye mail_index_modseq_sync_map_replaced(ctx->modseq_ctx);
f0ca07e08967a974684daffd32316cc9f9b98150Trond Norbyemail_index_header_update_counts(struct mail_index_header *hdr,
f0ca07e08967a974684daffd32316cc9f9b98150Trond Norbye const char **error_r)
45d862b9c655542aa44c02958011065f6994f512Trond Norbye if (((old_flags ^ new_flags) & MAIL_SEEN) != 0) {
const char *error;
unsigned int i, count;
for (i = 0; i < count; i++) {
&error) < 0)
const char *error;
if (all) {
&error) < 0)
unsigned int i, count;
for (i = 0; i < count; i++) {
unsigned int i, count;
for (i = 0; i < count; i++, e++) {
FALSE);
void *dest;
if (!MAIL_TRANSACTION_FLAG_UPDATE_IS_INTERNAL(u)) {
/* we're not modifying any counted/lowwatered flags */
if (orig_uid_validity != 0 &&
const void *data)
int ret = 0;
case MAIL_TRANSACTION_APPEND: {
if (ret <= 0)
case MAIL_TRANSACTION_EXPUNGE:
case MAIL_TRANSACTION_FLAG_UPDATE: {
if (ret <= 0)
case MAIL_TRANSACTION_HEADER_UPDATE: {
if (ret <= 0)
case MAIL_TRANSACTION_EXT_INTRO: {
if (ret <= 0)
case MAIL_TRANSACTION_EXT_RESET: {
case MAIL_TRANSACTION_EXT_HDR_UPDATE: {
if (ret <= 0)
case MAIL_TRANSACTION_EXT_REC_UPDATE: {
unsigned int i, record_size;
if (ret <= 0)
case MAIL_TRANSACTION_EXT_ATOMIC_INC: {
if (ret <= 0)
case MAIL_TRANSACTION_KEYWORD_UPDATE: {
case MAIL_TRANSACTION_KEYWORD_RESET: {
return ret;
#ifdef DEBUG
del++;
seen++;
const void *tdata;
int ret;
if (ret <= 0) {
if (had_dirty) {
if (reset) {
&tdata)) > 0) {
T_BEGIN {
} T_END;
if (had_dirty)
#ifdef DEBUG