sdbox-sync.c revision badb675af0ee245ffff36e5809ecc4e9526403d5
/* Copyright (c) 2007-2012 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "dbox-attachment.h"
#include "sdbox-storage.h"
#include "sdbox-file.h"
#include "sdbox-sync.h"
#define SDBOX_REBUILD_COUNT 3
static void
enum sdbox_sync_entry_type type)
{
bool deleted;
!move_to_alt) {
/* unopened dbox files default to primary dir.
stat the file to update its location. */
}
/* move the file. if it fails, nothing broke so
don't worry about it. */
}
}
enum sdbox_sync_entry_type type)
{
enum modify_type modify_type;
switch (type) {
}
break;
/* update flags in the sync transaction, mainly to make
sure that these alt changes get marked as synced
and won't be retried */
(enum mail_flags)DBOX_INDEX_FLAG_ALT);
break;
}
}
const struct mail_index_sync_rec *sync_rec)
{
enum sdbox_sync_entry_type type;
/* we're interested */
/* we care only about alt flag changes */
else
return;
} else {
/* not interested */
return;
}
/* already expunged everything. nothing to do. */
return;
}
}
}
{
const struct mail_index_header *hdr;
struct mail_index_sync_rec sync_rec;
if (hdr->uid_validity == 0) {
/* newly created index file */
"sdbox %s: Broken index: missing UIDVALIDITY",
return 0;
}
/* mark the newly seen messages as recent */
return 1;
}
{
struct sdbox_file *sfile;
int ret;
else
/* do sync_notify only when the file was unlinked by us */
}
{
/* NOTE: Index is no longer locked. Multiple processes may be unlinking
the files at the same time. */
}
static int
{
struct mail_index_view *view;
struct sdbox_index_header hdr;
int ret;
}
return ret;
}
struct sdbox_sync_context **ctx_r)
{
struct sdbox_sync_context *ctx;
unsigned int i;
int ret;
bool rebuild, force_rebuild;
rebuild = force_rebuild ||
mbox->corrupted_rebuild_count != 0 ||
if ((flags & SDBOX_SYNC_FLAG_FSYNC) != 0)
/* don't write unnecessary dirty flag updates */
for (i = 0;; i++) {
if (ret <= 0) {
if (ret < 0)
return ret;
}
if (rebuild)
ret = 0;
else {
break;
}
/* failure. keep the index locked while we're doing a
rebuild. */
if (ret == 0) {
if (i >= SDBOX_REBUILD_COUNT) {
"sdbox %s: Index keeps breaking",
ret = -1;
} else {
/* do a full resync and try again. */
}
}
if (ret < 0) {
return -1;
}
}
return 0;
}
{
if (success) {
ret = -1;
} else {
}
} else {
}
return ret;
}
{
struct sdbox_sync_context *sync_ctx;
return -1;
return 0;
}
struct mailbox_sync_context *
{
enum sdbox_sync_flags sdbox_sync_flags = 0;
int ret = 0;
if (mailbox_open(box) < 0)
ret = -1;
}
mbox->corrupted_rebuild_count != 0)) {
if ((flags & MAILBOX_SYNC_FLAG_FORCE_RESYNC) != 0)
}
}