dovecot-2.2: replicator: Replicator queue export/import at exit/...

dovecot at dovecot.org dovecot at dovecot.org
Sun Mar 24 17:04:33 EET 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/1af7c6f22793
changeset: 16099:1af7c6f22793
user:      Timo Sirainen <tss at iki.fi>
date:      Sun Mar 24 17:04:22 2013 +0200
description:
replicator: Replicator queue export/import at exit/startup wasn't really working.

diffstat:

 src/replication/replicator/replicator-queue.c |  24 +++++++++++++++++-------
 1 files changed, 17 insertions(+), 7 deletions(-)

diffs (68 lines):

diff -r 85f4f6ff4551 -r 1af7c6f22793 src/replication/replicator/replicator-queue.c
--- a/src/replication/replicator/replicator-queue.c	Sun Mar 24 16:53:32 2013 +0200
+++ b/src/replication/replicator/replicator-queue.c	Sun Mar 24 17:04:22 2013 +0200
@@ -256,24 +256,27 @@
 static int
 replicator_queue_import_line(struct replicator_queue *queue, const char *line)
 {
-	const char *const *args, *username;
+	const char *const *args, *username, *state;
 	unsigned int priority;
 	struct replicator_user *user, tmp_user;
 
-	/* <user> <priority> <last update> <last fast sync> <last full sync> */
+	/* <user> <priority> <last update> <last fast sync> <last full sync>
+	   <last failed> <state> */
 	args = t_strsplit_tabescaped(line);
-	if (str_array_length(args) < 5)
+	if (str_array_length(args) < 7)
 		return -1;
 
 	memset(&tmp_user, 0, sizeof(tmp_user));
 	username = args[0];
+	state = t_strdup_noconst(args[6]);
 	if (username[0] == '\0' ||
 	    str_to_uint(args[1], &priority) < 0 ||
 	    str_to_time(args[2], &tmp_user.last_update) < 0 ||
 	    str_to_time(args[3], &tmp_user.last_fast_sync) < 0 ||
-	    str_to_time(args[3], &tmp_user.last_full_sync) < 0)
+	    str_to_time(args[4], &tmp_user.last_full_sync) < 0)
 		return -1;
 	tmp_user.priority = priority;
+	tmp_user.last_sync_failed = args[5][0] != '0';
 
 	user = hash_table_lookup(queue->user_hash, username);
 	if (user != NULL) {
@@ -288,11 +291,14 @@
 				return 0;
 		}
 	}
-	user = replicator_queue_add(queue, tmp_user.username,
+	user = replicator_queue_add(queue, username,
 				    tmp_user.priority);
 	user->last_update = tmp_user.last_update;
 	user->last_fast_sync = tmp_user.last_fast_sync;
 	user->last_full_sync = tmp_user.last_full_sync;
+	user->last_sync_failed = tmp_user.last_sync_failed;
+	i_free(user->state);
+	user->state = i_strdup(state);
 	return 0;
 }
 
@@ -330,10 +336,14 @@
 replicator_queue_export_user(struct replicator_user *user, string_t *str)
 {
 	str_append_tabescaped(str, user->username);
-	str_printfa(str, "\t%d\t%lld\t%lld\t%lld", (int)user->priority,
+	str_printfa(str, "\t%d\t%lld\t%lld\t%lld\t%d\t", (int)user->priority,
 		    (long long)user->last_update,
 		    (long long)user->last_fast_sync,
-		    (long long)user->last_full_sync);
+		    (long long)user->last_full_sync,
+		    user->last_sync_failed);
+	if (user->state != NULL)
+		str_append_tabescaped(str, user->state);
+	str_append_c(str, '\n');
 }
 
 int replicator_queue_export(struct replicator_queue *queue, const char *path)


More information about the dovecot-cvs mailing list