From 9261897629d74626aaa8212daa6803c147816291 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Sat, 30 Mar 2013 16:27:11 +0100 Subject: [PATCH] don't record newuid in the sync state this value is only ever used to find just pushed messages by TUID, so we can simply use the UIDNEXT value from before we started pushing - and of course, we need to record that in the journal. it makes no sense to log the new value after completing a search, as there won't be a next search before we push the next messages. --- src/run-tests.pl | 4 ++-- src/sync.c | 13 ++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/run-tests.pl b/src/run-tests.pl index 25eae65..a500d12 100755 --- a/src/run-tests.pl +++ b/src/run-tests.pl @@ -367,7 +367,7 @@ sub showstate($) close FILE; return; } - if (!/^1:(\d+):0 1:(\d+):(\d+):0\n$/) { + if (!/^1:(\d+) 1:(\d+):(\d+)\n$/) { print STDERR " Malformed sync state header '$_'.\n"; close FILE; return; @@ -508,7 +508,7 @@ sub ckstate($@) return 1; } chomp($l); - my $xl = "1:".shift(@T).":0 1:".shift(@T).":".shift(@T).":0"; + my $xl = "1:".shift(@T)." 1:".shift(@T).":".shift(@T); if ($l ne $xl) { print STDERR "Sync state header mismatch: '$l' instead of '$xl'.\n"; return 1; diff --git a/src/sync.c b/src/sync.c index dfdc96a..220399f 100644 --- a/src/sync.c +++ b/src/sync.c @@ -725,8 +725,8 @@ box_selected( int sts, void *aux ) return; } if (sscanf( buf, "%63s %63s", buf1, buf2 ) != 2 || - sscanf( buf1, "%d:%d:%d", &svars->uidval[M], &svars->maxuid[M], &svars->newuid[M] ) < 2 || - sscanf( buf2, "%d:%d:%d:%d", &svars->uidval[S], &svars->smaxxuid, &svars->maxuid[S], &svars->newuid[S] ) < 3) { + sscanf( buf1, "%d:%d", &svars->uidval[M], &svars->maxuid[M] ) < 2 || + sscanf( buf2, "%d:%d:%d", &svars->uidval[S], &svars->smaxxuid, &svars->maxuid[S] ) < 3) { error( "Error: invalid sync state header in %s\n", svars->dname ); goto jbail; } @@ -1045,7 +1045,6 @@ box_loaded( int sts, void *aux ) debug( "matching previously copied messages on %s\n", str_ms[t] ); match_tuids( svars, t ); } - Fprintf( svars->jfp, "%c %d\n", "{}"[t], svars->ctx[t]->uidnext ); debug( "matching messages on %s against sync records\n", str_ms[t] ); hashsz = bucketsForSize( svars->nsrecs * 3 ); @@ -1161,6 +1160,7 @@ box_loaded( int sts, void *aux ) debug( "synchronizing new entries\n" ); svars->osrecadd = svars->srecadd; for (t = 0; t < 2; t++) { + Fprintf( svars->jfp, "%c %d\n", "{}"[t], svars->ctx[t]->uidnext ); for (tmsg = svars->ctx[1-t]->msgs; tmsg; tmsg = tmsg->next) if (tmsg->srec ? tmsg->srec->uid[t] < 0 && (tmsg->srec->uid[t] == -1 ? (svars->chan->ops[t] & OP_RENEW) : (svars->chan->ops[t] & OP_NEW)) : (svars->chan->ops[t] & OP_NEW)) { debug( "new message %d on %s\n", tmsg->uid, str_ms[1-t] ); @@ -1461,7 +1461,6 @@ msgs_found_new( int sts, void *aux ) static void msgs_new_done( sync_vars_t *svars, int t ) { - Fprintf( svars->jfp, "%c %d\n", "{}"[t], svars->ctx[t]->uidnext ); svars->state[t] |= ST_FOUND_NEW; sync_close( svars, t ); } @@ -1695,9 +1694,9 @@ box_closed_p2( sync_vars_t *svars, int t ) } } - Fprintf( svars->nfp, "%d:%d:%d %d:%d:%d:%d\n", - svars->uidval[M], svars->maxuid[M], svars->ctx[M]->uidnext, - svars->uidval[S], svars->smaxxuid, svars->maxuid[S], svars->ctx[S]->uidnext ); + Fprintf( svars->nfp, "%d:%d %d:%d:%d\n", + svars->uidval[M], svars->maxuid[M], + svars->uidval[S], svars->smaxxuid, svars->maxuid[S] ); for (srec = svars->srecs; srec; srec = srec->next) { if (srec->status & S_DEAD) continue;