Lines Matching defs:atomic
24 struct mdbox_map_atomic_context *atomic;
472 struct mdbox_map_atomic_context *atomic;
474 atomic = i_new(struct mdbox_map_atomic_context, 1);
475 atomic->map = map;
476 return atomic;
498 int mdbox_map_atomic_lock(struct mdbox_map_atomic_context *atomic,
503 if (atomic->locked)
506 if (mdbox_map_open_or_create(atomic->map) < 0)
511 ret = mail_index_sync_begin(atomic->map->index, &atomic->sync_ctx,
512 &atomic->sync_view, &atomic->sync_trans,
514 if (mail_index_reset_fscked(atomic->map->index))
515 mdbox_storage_set_corrupted(atomic->map->storage);
518 mail_storage_set_index_error(MAP_STORAGE(atomic->map),
519 atomic->map->index);
522 mail_index_sync_set_reason(atomic->sync_ctx, reason);
523 atomic->locked = TRUE;
526 atomic->map_refreshed = FALSE;
527 mdbox_map_sync_handle(atomic->map, atomic->sync_ctx);
531 bool mdbox_map_atomic_is_locked(struct mdbox_map_atomic_context *atomic)
533 return atomic->locked;
536 void mdbox_map_atomic_set_failed(struct mdbox_map_atomic_context *atomic)
538 atomic->success = FALSE;
539 atomic->failed = TRUE;
542 void mdbox_map_atomic_set_success(struct mdbox_map_atomic_context *atomic)
544 if (!atomic->failed)
545 atomic->success = TRUE;
548 void mdbox_map_atomic_unset_fscked(struct mdbox_map_atomic_context *atomic)
550 mail_index_unset_fscked(atomic->sync_trans);
555 struct mdbox_map_atomic_context *atomic = *_atomic;
560 if (atomic->sync_ctx == NULL) {
562 i_assert(!atomic->locked);
563 } else if (atomic->success) {
564 if (mail_index_sync_commit(&atomic->sync_ctx) < 0) {
565 mail_storage_set_index_error(MAP_STORAGE(atomic->map),
566 atomic->map->index);
570 mail_index_sync_rollback(&atomic->sync_ctx);
572 i_free(atomic);
577 mdbox_map_transaction_begin(struct mdbox_map_atomic_context *atomic,
589 ctx->atomic = atomic;
590 if (atomic->locked && atomic->map_refreshed) {
594 success = mdbox_map_open(atomic->map) > 0 &&
595 mdbox_map_refresh(atomic->map) == 0;
599 atomic->map_refreshed = TRUE;
600 ctx->trans = mail_index_transaction_begin(atomic->map->view,
615 if (mdbox_map_atomic_lock(ctx->atomic, reason) < 0)
619 mail_storage_set_index_error(MAP_STORAGE(ctx->atomic->map),
620 ctx->atomic->map->index);
623 mdbox_map_atomic_set_success(ctx->atomic);
641 struct mdbox_map *map = ctx->atomic->map;
704 struct mdbox_map_atomic_context *atomic;
716 atomic = mdbox_map_atomic_begin(map);
717 map_trans = mdbox_map_transaction_begin(atomic, TRUE);
738 if (mdbox_map_atomic_finish(&atomic) < 0)
744 mdbox_map_append_begin(struct mdbox_map_atomic_context *atomic)
749 ctx->atomic = atomic;
750 ctx->map = atomic->map;
756 if (mdbox_map_open_or_create(atomic->map) < 0)
761 if (mdbox_map_refresh(atomic->map) == 0)
762 atomic->map_refreshed = TRUE;
1227 if (mdbox_map_atomic_lock(ctx->atomic, reason) < 0)
1230 mdbox_map_get_ext_hdr(ctx->map, ctx->atomic->sync_view, &hdr);
1268 ctx->atomic->sync_trans,
1321 hdr = mail_index_get_header(ctx->atomic->sync_view);
1364 next_uid = mail_index_get_header(ctx->atomic->sync_view)->next_uid;
1376 if (!mail_index_lookup_seq(ctx->atomic->sync_view,
1383 mail_index_append(ctx->atomic->sync_trans,
1386 mail_index_update_ext(ctx->atomic->sync_trans, seq,
1392 if (!mail_index_lookup_seq(ctx->atomic->sync_view, uid, &seq))
1394 mail_index_expunge(ctx->atomic->sync_trans, seq);
1426 mdbox_map_atomic_set_success(ctx->atomic);