From: Timo Sirainen Date: Wed, 29 Jun 2016 19:29:20 +0000 (+0300) Subject: dsync: When full resync is wanted in a stateful sync, output empty state. X-Git-Tag: 2.2.25.rc1~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7be176606f0e096e13df9fa5b4ea9a161af423cf;p=thirdparty%2Fdovecot%2Fcore.git dsync: When full resync is wanted in a stateful sync, output empty state. This continues 3d49dc64d, which didn't actually work because brain->require_full_resync was either cleared earlier or it was never even set in this brain. --- diff --git a/src/doveadm/dsync/dsync-brain-mailbox.c b/src/doveadm/dsync/dsync-brain-mailbox.c index fa43537bd9..bd380645bb 100644 --- a/src/doveadm/dsync/dsync-brain-mailbox.c +++ b/src/doveadm/dsync/dsync-brain-mailbox.c @@ -343,10 +343,6 @@ void dsync_brain_sync_mailbox_deinit(struct dsync_brain *brain) i_assert(brain->box != NULL); - if (brain->require_full_resync) { - brain->mailbox_state.last_uidvalidity = 0; - brain->require_full_resync = FALSE; - } array_append(&brain->remote_mailbox_states, &brain->mailbox_state, 1); if (brain->box_exporter != NULL) { const char *errstr; diff --git a/src/doveadm/dsync/dsync-brain.c b/src/doveadm/dsync/dsync-brain.c index 3191708ead..22b07aa6c9 100644 --- a/src/doveadm/dsync/dsync-brain.c +++ b/src/doveadm/dsync/dsync-brain.c @@ -568,16 +568,19 @@ static bool dsync_brain_finish(struct dsync_brain *brain) { const char *error; enum mail_error mail_error; + bool require_full_resync; enum dsync_ibc_recv_ret ret; if (!brain->master_brain) { dsync_ibc_send_finish(brain->ibc, brain->failed ? "dsync failed" : NULL, - brain->mail_error); + brain->mail_error, + brain->require_full_resync); brain->state = DSYNC_STATE_DONE; return TRUE; } - ret = dsync_ibc_recv_finish(brain->ibc, &error, &mail_error); + ret = dsync_ibc_recv_finish(brain->ibc, &error, &mail_error, + &require_full_resync); if (ret == DSYNC_IBC_RECV_RET_TRYAGAIN) return FALSE; if (error != NULL) { @@ -587,6 +590,8 @@ static bool dsync_brain_finish(struct dsync_brain *brain) (brain->mail_error == 0 || brain->mail_error == MAIL_ERROR_TEMP)) brain->mail_error = mail_error; } + if (require_full_resync) + brain->require_full_resync = TRUE; brain->state = DSYNC_STATE_DONE; return TRUE; } diff --git a/src/doveadm/dsync/dsync-ibc-pipe.c b/src/doveadm/dsync/dsync-ibc-pipe.c index 16b573c2a6..c8a1841d56 100644 --- a/src/doveadm/dsync/dsync-ibc-pipe.c +++ b/src/doveadm/dsync/dsync-ibc-pipe.c @@ -45,6 +45,7 @@ struct item { struct { const char *error; enum mail_error mail_error; + bool require_full_resync; } finish; } u; }; @@ -491,7 +492,8 @@ dsync_ibc_pipe_recv_mail(struct dsync_ibc *ibc, struct dsync_mail **mail_r) static void dsync_ibc_pipe_send_finish(struct dsync_ibc *ibc, const char *error, - enum mail_error mail_error) + enum mail_error mail_error, + bool require_full_resync) { struct dsync_ibc_pipe *pipe = (struct dsync_ibc_pipe *)ibc; struct item *item; @@ -499,11 +501,13 @@ dsync_ibc_pipe_send_finish(struct dsync_ibc *ibc, const char *error, item = dsync_ibc_pipe_push_item(pipe->remote, ITEM_FINISH); item->u.finish.error = p_strdup(item->pool, error); item->u.finish.mail_error = mail_error; + item->u.finish.require_full_resync = require_full_resync; } static enum dsync_ibc_recv_ret dsync_ibc_pipe_recv_finish(struct dsync_ibc *ibc, const char **error_r, - enum mail_error *mail_error_r) + enum mail_error *mail_error_r, + bool *require_full_resync_r) { struct dsync_ibc_pipe *pipe = (struct dsync_ibc_pipe *)ibc; struct item *item; @@ -514,6 +518,7 @@ dsync_ibc_pipe_recv_finish(struct dsync_ibc *ibc, const char **error_r, *error_r = item->u.finish.error; *mail_error_r = item->u.finish.mail_error; + *require_full_resync_r = item->u.finish.require_full_resync; return DSYNC_IBC_RECV_RET_OK; } diff --git a/src/doveadm/dsync/dsync-ibc-private.h b/src/doveadm/dsync/dsync-ibc-private.h index 62112c0e9c..9ee1d38455 100644 --- a/src/doveadm/dsync/dsync-ibc-private.h +++ b/src/doveadm/dsync/dsync-ibc-private.h @@ -69,10 +69,12 @@ struct dsync_ibc_vfuncs { struct dsync_mail **mail_r); void (*send_finish)(struct dsync_ibc *ibc, const char *error, - enum mail_error mail_error); + enum mail_error mail_error, + bool require_full_resync); enum dsync_ibc_recv_ret (*recv_finish)(struct dsync_ibc *ibc, const char **error_r, - enum mail_error *mail_error_r); + enum mail_error *mail_error_r, + bool *require_full_resync_r); void (*close_mail_streams)(struct dsync_ibc *ibc); bool (*is_send_queue_full)(struct dsync_ibc *ibc); diff --git a/src/doveadm/dsync/dsync-ibc-stream.c b/src/doveadm/dsync/dsync-ibc-stream.c index 102fffe855..a042fffaa0 100644 --- a/src/doveadm/dsync/dsync-ibc-stream.c +++ b/src/doveadm/dsync/dsync-ibc-stream.c @@ -125,7 +125,7 @@ static const struct { }, { .name = "finish", .chr = 'F', - .optional_keys = "error mail_error", + .optional_keys = "error mail_error require_full_resync", .min_minor_version = DSYNC_PROTOCOL_MINOR_HAVE_FINISH }, { .name = "mailbox_cache_field", @@ -1906,7 +1906,8 @@ dsync_ibc_stream_recv_mail(struct dsync_ibc *_ibc, struct dsync_mail **mail_r) static void dsync_ibc_stream_send_finish(struct dsync_ibc *_ibc, const char *error, - enum mail_error mail_error) + enum mail_error mail_error, + bool require_full_resync) { struct dsync_ibc_stream *ibc = (struct dsync_ibc_stream *)_ibc; struct dsync_serializer_encoder *encoder; @@ -1920,13 +1921,16 @@ dsync_ibc_stream_send_finish(struct dsync_ibc *_ibc, const char *error, dsync_serializer_encode_add(encoder, "mail_error", dec2str(mail_error)); } + if (require_full_resync) + dsync_serializer_encode_add(encoder, "require_full_resync", ""); dsync_serializer_encode_finish(&encoder, str); dsync_ibc_stream_send_string(ibc, str); } static enum dsync_ibc_recv_ret dsync_ibc_stream_recv_finish(struct dsync_ibc *_ibc, const char **error_r, - enum mail_error *mail_error_r) + enum mail_error *mail_error_r, + bool *require_full_resync_r) { struct dsync_ibc_stream *ibc = (struct dsync_ibc_stream *)_ibc; struct dsync_deserializer_decoder *decoder; @@ -1936,6 +1940,7 @@ dsync_ibc_stream_recv_finish(struct dsync_ibc *_ibc, const char **error_r, *error_r = NULL; *mail_error_r = 0; + *require_full_resync_r = FALSE; p_clear(ibc->ret_pool); @@ -1953,6 +1958,8 @@ dsync_ibc_stream_recv_finish(struct dsync_ibc *_ibc, const char **error_r, dsync_ibc_input_error(ibc, decoder, "Invalid mail_error"); return DSYNC_IBC_RECV_RET_TRYAGAIN; } + if (dsync_deserializer_decode_try(decoder, "require_full_resync", &value)) + *require_full_resync_r = TRUE; *mail_error_r = i; ibc->finish_received = TRUE; diff --git a/src/doveadm/dsync/dsync-ibc.c b/src/doveadm/dsync/dsync-ibc.c index e9eea93109..f85bed30cb 100644 --- a/src/doveadm/dsync/dsync-ibc.c +++ b/src/doveadm/dsync/dsync-ibc.c @@ -196,16 +196,19 @@ dsync_ibc_recv_mail(struct dsync_ibc *ibc, struct dsync_mail **mail_r) } void dsync_ibc_send_finish(struct dsync_ibc *ibc, const char *error, - enum mail_error mail_error) + enum mail_error mail_error, + bool require_full_resync) { - ibc->v.send_finish(ibc, error, mail_error); + ibc->v.send_finish(ibc, error, mail_error, require_full_resync); } enum dsync_ibc_recv_ret dsync_ibc_recv_finish(struct dsync_ibc *ibc, const char **error_r, - enum mail_error *mail_error_r) + enum mail_error *mail_error_r, + bool *require_full_resync_r) { - return ibc->v.recv_finish(ibc, error_r, mail_error_r); + return ibc->v.recv_finish(ibc, error_r, mail_error_r, + require_full_resync_r); } void dsync_ibc_close_mail_streams(struct dsync_ibc *ibc) diff --git a/src/doveadm/dsync/dsync-ibc.h b/src/doveadm/dsync/dsync-ibc.h index d35d9211ec..66b4026cea 100644 --- a/src/doveadm/dsync/dsync-ibc.h +++ b/src/doveadm/dsync/dsync-ibc.h @@ -148,10 +148,12 @@ enum dsync_ibc_recv_ret dsync_ibc_recv_mail(struct dsync_ibc *ibc, struct dsync_mail **mail_r); void dsync_ibc_send_finish(struct dsync_ibc *ibc, const char *error, - enum mail_error mail_error); + enum mail_error mail_error, + bool require_full_resync); enum dsync_ibc_recv_ret dsync_ibc_recv_finish(struct dsync_ibc *ibc, const char **error_r, - enum mail_error *mail_error_r); + enum mail_error *mail_error_r, + bool *require_full_resync_r); /* Close any mail input streams that are kept open. This needs to be called before the mail is attempted to be freed (usually on error conditions). */