dovecot-2.2: doveadm replicator replicate: Added -f parameter to...
dovecot at dovecot.org
dovecot at dovecot.org
Wed Apr 23 17:55:27 UTC 2014
details: http://hg.dovecot.org/dovecot-2.2/rev/df172c4de57e
changeset: 17254:df172c4de57e
user: Timo Sirainen <tss at iki.fi>
date: Wed Apr 23 20:55:04 2014 +0300
description:
doveadm replicator replicate: Added -f parameter to force a full sync for user.
diffstat:
src/doveadm/doveadm-replicator.c | 11 +++++++++--
src/replication/replicator/doveadm-connection.c | 16 +++++++++++-----
src/replication/replicator/replicator-brain.c | 4 +++-
src/replication/replicator/replicator-queue.h | 2 ++
4 files changed, 25 insertions(+), 8 deletions(-)
diffs (118 lines):
diff -r b4e2048e5312 -r df172c4de57e src/doveadm/doveadm-replicator.c
--- a/src/doveadm/doveadm-replicator.c Wed Apr 23 20:53:55 2014 +0300
+++ b/src/doveadm/doveadm-replicator.c Wed Apr 23 20:55:04 2014 +0300
@@ -19,6 +19,7 @@
const char *socket_path;
const char *priority;
struct istream *input;
+ bool full_sync;
};
extern struct doveadm_cmd doveadm_cmd_replicator[];
@@ -85,6 +86,9 @@
case 'a':
ctx->socket_path = optarg;
break;
+ case 'f':
+ ctx->full_sync = TRUE;
+ break;
case 'p':
ctx->priority = optarg;
break;
@@ -221,7 +225,7 @@
if (argv[1] == NULL)
replicator_cmd_help(cmd_replicator_replicate);
- ctx = cmd_replicator_init(&argc, &argv, "a:p:", cmd_replicator_replicate);
+ ctx = cmd_replicator_init(&argc, &argv, "a:fp:", cmd_replicator_replicate);
str = t_str_new(128);
str_append(str, "REPLICATE\t");
@@ -230,6 +234,9 @@
else
str_append_tabescaped(str, ctx->priority);
str_append_c(str, '\t');
+ if (ctx->full_sync)
+ str_append_c(str, 'f');
+ str_append_c(str, '\t');
str_append_tabescaped(str, argv[1]);
str_append_c(str, '\n');
replicator_send(ctx, str_c(str));
@@ -285,7 +292,7 @@
{ cmd_replicator_dsync_status, "replicator dsync-status",
"[-a <replicator socket path>]" },
{ cmd_replicator_replicate, "replicator replicate",
- "[-a <replicator socket path>] [-p <priority>] <user mask>" },
+ "[-a <replicator socket path>] [-f] [-p <priority>] <user mask>" },
{ cmd_replicator_remove, "replicator remove",
"[-a <replicator socket path>] <username>" },
};
diff -r b4e2048e5312 -r df172c4de57e src/replication/replicator/doveadm-connection.c
--- a/src/replication/replicator/doveadm-connection.c Wed Apr 23 20:53:55 2014 +0300
+++ b/src/replication/replicator/doveadm-connection.c Wed Apr 23 20:55:04 2014 +0300
@@ -156,9 +156,10 @@
const char *usermask;
enum replication_priority priority;
unsigned int match_count;
+ bool full;
- /* <priority> <username>|<mask> */
- if (str_array_length(args) != 2) {
+ /* <priority> <flags> <username>|<mask> */
+ if (str_array_length(args) != 3) {
i_error("%s: REPLICATE: Invalid parameters", client->conn.name);
return -1;
}
@@ -166,9 +167,12 @@
o_stream_send_str(client->conn.output, "-Invalid priority\n");
return 0;
}
- usermask = args[1];
+ full = strchr(args[1], 'f') != NULL;
+ usermask = args[2];
if (strchr(usermask, '*') == NULL && strchr(usermask, '?') == NULL) {
- replicator_queue_add(queue, usermask, priority);
+ user = replicator_queue_add(queue, usermask, priority);
+ if (full)
+ user->force_full_sync = TRUE;
o_stream_send_str(client->conn.output, "+1\n");
return 0;
}
@@ -178,7 +182,9 @@
while ((user = replicator_queue_iter_next(iter)) != NULL) {
if (!wildcard_match(user->username, usermask))
continue;
- replicator_queue_add(queue, user->username, priority);
+ user = replicator_queue_add(queue, user->username, priority);
+ if (full)
+ user->force_full_sync = TRUE;
match_count++;
}
replicator_queue_iter_deinit(&iter);
diff -r b4e2048e5312 -r df172c4de57e src/replication/replicator/replicator-brain.c
--- a/src/replication/replicator/replicator-brain.c Wed Apr 23 20:53:55 2014 +0300
+++ b/src/replication/replicator/replicator-brain.c Wed Apr 23 20:55:04 2014 +0300
@@ -141,8 +141,10 @@
/* update the sync times immediately. if the replication fails we still
wouldn't want it to be retried immediately. */
user->last_fast_sync = ioloop_time;
- if (full)
+ if (full || user->force_full_sync) {
user->last_full_sync = ioloop_time;
+ user->force_full_sync = FALSE;
+ }
/* reset priority also. if more updates arrive during replication
we'll do another replication to make sure nothing gets lost */
user->priority = REPLICATION_PRIORITY_NONE;
diff -r b4e2048e5312 -r df172c4de57e src/replication/replicator/replicator-queue.h
--- a/src/replication/replicator/replicator-queue.h Wed Apr 23 20:53:55 2014 +0300
+++ b/src/replication/replicator/replicator-queue.h Wed Apr 23 20:55:04 2014 +0300
@@ -20,6 +20,8 @@
unsigned int popped:1;
/* Last replication sync failed */
unsigned int last_sync_failed:1;
+ /* Force a full sync on the next replication */
+ unsigned int force_full_sync:1;
};
typedef void replicator_sync_callback_t(bool success, void *context);
More information about the dovecot-cvs
mailing list