mail-transaction-log-append.c revision ad48319996942463675b53877092ab7e13a7a75a
/* Copyright (c) 2003-2009 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "write-full.h"
#include "mail-index-private.h"
#include "mail-transaction-log-private.h"
enum mail_transaction_type type,
{
struct mail_transaction_header hdr;
if (size == 0)
return;
if (type == MAIL_TRANSACTION_EXPUNGE ||
}
static int
{
/* first we need to truncate this latest write so that log syncing
doesn't break */
"ftruncate()");
}
return -1;
return 0;
}
{
struct mail_transaction_header *hdr;
return 0;
}
return 0;
}
/* size will be written later once everything is in disk */
i_assert(first_size != 0);
file->sync_offset) < 0) {
/* write failure, fallback to in-memory indexes. */
"pwrite_full()");
return log_buffer_move_to_memory(ctx);
}
/* now that the whole transaction has been written, rewrite the first
record's size so the transaction becomes visible */
file->sync_offset +
"pwrite_full()");
return log_buffer_move_to_memory(ctx);
}
"fdatasync()");
return log_buffer_move_to_memory(ctx);
}
}
/* FIXME: when we're relying on O_APPEND and someone else wrote a
transaction, we'll need to wait for it to commit its transaction.
if it crashes before doing that, we'll need to overwrite it with
a dummy record */
return 0;
}
static void
{
struct mail_transaction_header_update *u;
struct mail_transaction_header *hdr;
/* FIXME: when we remove exclusive log locking, we
can't rely on this. then write non-changed offset + check
real offset + rewrite the new offset if other transactions
weren't written in the middle */
}
return;
sizeof(*u) + sizeof(offset));
u = buffer_append_space_unsafe(buf, sizeof(*u));
}
static int
{
/* there is some garbage at the end of the transaction log
(eg. previous write failed). remove it so reader doesn't
break because of it. */
if (!MAIL_TRANSACTION_LOG_FILE_IN_MEMORY(file)) {
}
}
}
if (ctx->append_sync_offset)
if (log_buffer_write(ctx) < 0)
return -1;
return 0;
}
struct mail_transaction_log_append_ctx **ctx_r)
{
struct mail_transaction_log_append_ctx *ctx;
if (!index->log_locked) {
return -1;
}
return 0;
}
{
int ret = 0;
if (!index->log_locked)
return ret;
}