import_flags |= DSYNC_MAILBOX_IMPORT_FLAG_MAILS_USE_GUID128;
if (brain->no_notify)
import_flags |= DSYNC_MAILBOX_IMPORT_FLAG_NO_NOTIFY;
- if (brain->hdr_hash_v2)
- import_flags |= DSYNC_MAILBOX_IMPORT_FLAG_HDR_HASH_V2;
if (brain->empty_hdr_workaround)
import_flags |= DSYNC_MAILBOX_IMPORT_FLAG_EMPTY_HDR_WORKAROUND;
brain->sync_max_size,
brain->sync_flag,
brain->import_commit_msgs_interval,
- import_flags);
+ import_flags, brain->hdr_hash_version);
}
int dsync_brain_sync_mailbox_open(struct dsync_brain *brain,
exporter_flags |= DSYNC_MAILBOX_EXPORTER_FLAG_TIMESTAMPS;
if (brain->sync_max_size > 0)
exporter_flags |= DSYNC_MAILBOX_EXPORTER_FLAG_VSIZES;
- if (brain->hdr_hash_v2)
- exporter_flags |= DSYNC_MAILBOX_EXPORTER_FLAG_HDR_HASH_V2;
if (remote_dsync_box->messages_count == 0) {
/* remote mailbox is empty - we don't really need to export
header hashes since they're not going to match anything
brain->box_exporter = brain->backup_recv ? NULL :
dsync_mailbox_export_init(brain->box, brain->log_scan,
last_common_uid,
- exporter_flags);
+ exporter_flags,
+ brain->hdr_hash_version);
dsync_brain_sync_mailbox_init_remote(brain, remote_dsync_box);
return 1;
}
const char *sync_flag;
char alt_char;
unsigned int import_commit_msgs_interval;
+ unsigned int hdr_hash_version;
unsigned int lock_timeout;
int lock_fd;
unsigned int require_full_resync:1;
unsigned int verbose_proctitle:1;
unsigned int no_notify:1;
- unsigned int hdr_hash_v2:1;
unsigned int failed:1;
unsigned int empty_hdr_workaround:1;
};
return brain->lock_fd == -1 ? -1 : 0;
}
+static void
+dsync_brain_set_hdr_hash_version(struct dsync_brain *brain,
+ const struct dsync_ibc_settings *ibc_set)
+{
+ if (ibc_set->hdr_hash_v3)
+ brain->hdr_hash_version = 3;
+ else if (ibc_set->hdr_hash_v2)
+ brain->hdr_hash_version = 3;
+ else
+ brain->hdr_hash_version = 1;
+}
+
static bool dsync_brain_master_recv_handshake(struct dsync_brain *brain)
{
const struct dsync_ibc_settings *ibc_set;
return FALSE;
}
}
- brain->hdr_hash_v2 = ibc_set->hdr_hash_v2;
+ dsync_brain_set_hdr_hash_version(brain, ibc_set);
brain->state = brain->sync_type == DSYNC_BRAIN_SYNC_TYPE_STATE ?
DSYNC_STATE_MASTER_SEND_LAST_COMMON :
if (dsync_ibc_recv_handshake(brain->ibc, &ibc_set) == 0)
return FALSE;
- brain->hdr_hash_v2 = ibc_set->hdr_hash_v2;
+ dsync_brain_set_hdr_hash_version(brain, ibc_set);
if (ibc_set->lock_timeout > 0) {
brain->lock_timeout = ibc_set->lock_timeout;
#define DSYNC_IBC_STREAM_OUTBUF_THROTTLE_SIZE (1024*128)
#define DSYNC_PROTOCOL_VERSION_MAJOR 3
-#define DSYNC_PROTOCOL_VERSION_MINOR 4
-#define DSYNC_HANDSHAKE_VERSION "VERSION\tdsync\t3\t4\n"
+#define DSYNC_PROTOCOL_VERSION_MINOR 5
+#define DSYNC_HANDSHAKE_VERSION "VERSION\tdsync\t3\t5\n"
#define DSYNC_PROTOCOL_MINOR_HAVE_ATTRIBUTES 1
#define DSYNC_PROTOCOL_MINOR_HAVE_SAVE_GUID 2
#define DSYNC_PROTOCOL_MINOR_HAVE_FINISH 3
#define DSYNC_PROTOCOL_MINOR_HAVE_HDR_HASH_V2 4
+#define DSYNC_PROTOCOL_MINOR_HAVE_HDR_HASH_V3 5
enum item_type {
ITEM_NONE,
if (dsync_deserializer_decode_try(decoder, "empty_hdr_workaround", &value))
set->brain_flags |= DSYNC_BRAIN_FLAG_EMPTY_HDR_WORKAROUND;
set->hdr_hash_v2 = ibc->minor_version >= DSYNC_PROTOCOL_MINOR_HAVE_HDR_HASH_V2;
+ set->hdr_hash_v3 = ibc->minor_version >= DSYNC_PROTOCOL_MINOR_HAVE_HDR_HASH_V3;
*set_r = set;
return DSYNC_IBC_RECV_RET_OK;
enum dsync_brain_sync_type sync_type;
enum dsync_brain_flags brain_flags;
bool hdr_hash_v2;
+ bool hdr_hash_v3;
unsigned int lock_timeout;
unsigned int import_commit_msgs_interval;
};
dsync_mailbox_export_init(struct mailbox *box,
struct dsync_transaction_log_scan *log_scan,
uint32_t last_common_uid,
- enum dsync_mailbox_exporter_flags flags)
+ enum dsync_mailbox_exporter_flags flags,
+ unsigned int hdr_hash_version)
{
struct dsync_mailbox_exporter *exporter;
pool_t pool;
(flags & DSYNC_MAILBOX_EXPORTER_FLAG_TIMESTAMPS) != 0;
exporter->export_virtual_sizes =
(flags & DSYNC_MAILBOX_EXPORTER_FLAG_VSIZES) != 0;
- exporter->hdr_hash_version =
- (flags & DSYNC_MAILBOX_EXPORTER_FLAG_HDR_HASH_V2) ? 2 : 1;
+ exporter->hdr_hash_version = hdr_hash_version;
exporter->no_hdr_hashes =
(flags & DSYNC_MAILBOX_EXPORTER_FLAG_NO_HDR_HASHES) != 0;
p_array_init(&exporter->requested_uids, pool, 16);
DSYNC_MAILBOX_EXPORTER_FLAG_MAILS_HAVE_GUIDS = 0x02,
DSYNC_MAILBOX_EXPORTER_FLAG_MINIMAL_DMAIL_FILL = 0x04,
DSYNC_MAILBOX_EXPORTER_FLAG_TIMESTAMPS = 0x08,
- DSYNC_MAILBOX_EXPORTER_FLAG_HDR_HASH_V2 = 0x10,
DSYNC_MAILBOX_EXPORTER_FLAG_NO_HDR_HASHES = 0x20,
DSYNC_MAILBOX_EXPORTER_FLAG_VSIZES = 0x40,
};
dsync_mailbox_export_init(struct mailbox *box,
struct dsync_transaction_log_scan *log_scan,
uint32_t last_common_uid,
- enum dsync_mailbox_exporter_flags flags);
+ enum dsync_mailbox_exporter_flags flags,
+ unsigned int hdr_hash_version);
/* Returns 1 if attribute was returned, 0 if no more attributes, -1 on error */
int dsync_mailbox_export_next_attr(struct dsync_mailbox_exporter *exporter,
const struct dsync_mailbox_attribute **attr_r);
uoff_t sync_max_size,
const char *sync_flag,
unsigned int commit_msgs_interval,
- enum dsync_mailbox_import_flags flags)
+ enum dsync_mailbox_import_flags flags,
+ unsigned int hdr_hash_version)
{
struct dsync_mailbox_importer *importer;
struct mailbox_status status;
(flags & DSYNC_MAILBOX_IMPORT_FLAG_MAILS_HAVE_GUIDS) != 0;
importer->mails_use_guid128 =
(flags & DSYNC_MAILBOX_IMPORT_FLAG_MAILS_USE_GUID128) != 0;
- importer->hdr_hash_version =
- (flags & DSYNC_MAILBOX_IMPORT_FLAG_HDR_HASH_V2) != 0 ? 2 : 1;
+ importer->hdr_hash_version = hdr_hash_version;
importer->empty_hdr_workaround =
(flags & DSYNC_MAILBOX_IMPORT_FLAG_EMPTY_HDR_WORKAROUND) != 0;
DSYNC_MAILBOX_IMPORT_FLAG_MAILS_HAVE_GUIDS = 0x10,
DSYNC_MAILBOX_IMPORT_FLAG_MAILS_USE_GUID128 = 0x20,
DSYNC_MAILBOX_IMPORT_FLAG_NO_NOTIFY = 0x40,
- DSYNC_MAILBOX_IMPORT_FLAG_HDR_HASH_V2 = 0x80,
DSYNC_MAILBOX_IMPORT_FLAG_EMPTY_HDR_WORKAROUND = 0x100
};
uoff_t sync_max_size,
const char *sync_flag,
unsigned int commit_msgs_interval,
- enum dsync_mailbox_import_flags flags);
+ enum dsync_mailbox_import_flags flags,
+ unsigned int hdr_hash_version);
int dsync_mailbox_import_attribute(struct dsync_mailbox_importer *importer,
const struct dsync_mailbox_attribute *attr);
int dsync_mailbox_import_change(struct dsync_mailbox_importer *importer,