mail-index-sync-update.c revision b61a8c8f555a3ef1dd8edd63be04146c76eb66a7
c25356d5978632df6203437e1953bcb29e0c736fTimo Sirainen/* Copyright (C) 2004 Timo Sirainen */
d8702d15ee7721ed1fcfc8f00a589970bd6b3598Timo Sirainenmail_index_sync_update_log_offset(struct mail_index_sync_map_ctx *ctx,
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen mail_transaction_log_view_get_prev_pos(ctx->view->log_view,
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen if (prev_offset == ctx->ext_intro_end_offset &&
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen /* previous transaction was an extension introduction.
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen we probably came here from
d1414c09cf0d58ac983054e2f4e1a1f329272dcfTimo Sirainen mail_index_sync_ext_reset(). if there are any more
d1414c09cf0d58ac983054e2f4e1a1f329272dcfTimo Sirainen views which want to continue syncing it needs the
73bfdbe28c2ce6d143eadf0bab8ccfbe4cab0faeTimo Sirainen intro. so back up a bit more.
d1414c09cf0d58ac983054e2f4e1a1f329272dcfTimo Sirainen don't do this in case the last transaction in the
8eea67470c1bd8562a62e7445d930bb2079b1a43Timo Sirainen log is the extension intro, so we don't keep trying
8eea67470c1bd8562a62e7445d930bb2079b1a43Timo Sirainen to sync it over and over again. */
64e244defe74f513ce94f33d000a048ddbe2ea23Timo Sirainen i_assert(ctx->view->index->log->head->hdr.file_seq == prev_seq);
64e244defe74f513ce94f33d000a048ddbe2ea23Timo Sirainen#if 0 // FIXME: can we / do we want to support this?
9c3577aeb78a27920439ad9f1e62ee03699378c3Timo Sirainenmail_index_map_msync(struct mail_index *index, struct mail_index_map *map)
64e244defe74f513ce94f33d000a048ddbe2ea23Timo Sirainen buffer_write(map->hdr_copy_buf, 0, &map->hdr, sizeof(map->hdr));
6ef7e31619edfaa17ed044b45861d106a86191efTimo Sirainen I_MIN(map->hdr.base_header_size, sizeof(map->hdr)));
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen memcpy(PTR_OFFSET(map->mmap_base, map->hdr.base_header_size),
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen CONST_PTR_OFFSET(map->hdr_base, map->hdr.base_header_size),
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen map->hdr.header_size - map->hdr.base_header_size);
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen if (msync(map->mmap_base, map->mmap_used_size, MS_SYNC) < 0) {
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen mail_index_set_syscall_error(index, "msync()");
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainenstatic void mail_index_sync_replace_map(struct mail_index_sync_map_ctx *ctx,
d1414c09cf0d58ac983054e2f4e1a1f329272dcfTimo Sirainen mail_index_sync_update_log_offset(ctx, view->map, FALSE);
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen#if 0 // FIXME
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen /* we could have already updated some of the records, so make sure
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen that other views (in possibly other processes) will see this map's
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen header in a valid state. */
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen (void)mail_index_map_msync(view->index, view->map);
64e244defe74f513ce94f33d000a048ddbe2ea23Timo Sirainen if (ctx->type != MAIL_INDEX_SYNC_HANDLER_VIEW)
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainenvoid mail_index_sync_move_to_private(struct mail_index_sync_map_ctx *ctx)
3b8d05391336c0e4d24c8ddcc962f350409ffbd3Timo Sirainenmail_index_sync_get_atomic_map(struct mail_index_sync_map_ctx *ctx)
const char **error_r)
const char *error;
unsigned int i, count;
for (i = 0; i < count; i++, e++) {
if (seq1 == 0) {
void *dest;
if (seq1 == 0)
/* we're not modifying any counted/lowwatered flags */
const void *data)
int ret = 0;
t_push();
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_KEYWORD_UPDATE: {
case MAIL_TRANSACTION_KEYWORD_RESET: {
i_unreached();
t_pop();
return ret;
const void *tdata;
int ret;
bool had_dirty;
if (!force) {
if (ret <= 0) {
if (had_dirty) {
&tdata)) > 0) {
if (had_dirty)