isync

mailbox synchronization program
git clone https://git.code.sf.net/p/isync/isync
Log | Files | Refs | README | LICENSE

commit 61b08880c8de61a42897f4680b36cded02dc9e8b
parent 0f6362f2e2ecefa822c05854b2e48fa5638f96dc
Author: Oswald Buddenhagen <ossi@users.sf.net>
Date:   Fri, 10 Dec 2021 20:56:36 +0100

improve tracking of maxxfuid

do it when the corresponding expiration events are logged/replayed.
that makes it unnecessary to log it separately just to make the
autotest happy.

Diffstat:
Msrc/sync.c | 11++---------
Msrc/sync_p.h | 1-
Msrc/sync_state.c | 7++-----
3 files changed, 4 insertions(+), 15 deletions(-)

diff --git a/src/sync.c b/src/sync.c @@ -932,7 +932,6 @@ box_loaded( int sts, message_t *msgs, int total_msgs, int recent_msgs, void *aux svars->oldmaxuid[F] = svars->maxuid[F]; svars->oldmaxuid[N] = svars->maxuid[N]; - svars->oldmaxxfuid = svars->maxxfuid; info( "Synchronizing...\n" ); for (t = 0; t < 2; t++) @@ -1201,8 +1200,6 @@ box_loaded( int sts, message_t *msgs, int total_msgs, int recent_msgs, void *aux /* The message is excess or was already (being) expired. */ srec->status |= S_NEXPIRE; debug( " pair(%u,%u) expired\n", srec->uid[F], srec->uid[N] ); - if (svars->maxxfuid < srec->uid[F]) - svars->maxxfuid = srec->uid[F]; todel--; } } @@ -1505,6 +1502,8 @@ flags_set_p2( sync_vars_t *svars, sync_rec_t *srec, int t ) if (t == N) { uchar nex = (srec->status / S_NEXPIRE) & 1; if (nex != ((srec->status / S_EXPIRED) & 1)) { + if (nex && svars->maxxfuid < srec->uid[F]) + svars->maxxfuid = srec->uid[F]; srec->status = (srec->status & ~S_EXPIRED) | (nex * S_EXPIRED); JLOG( "~ %u %u %d", (srec->uid[F], srec->uid[N], srec->status & S_LOGGED), "expired %d - commit", nex ); @@ -1728,12 +1727,6 @@ box_closed_p2( sync_vars_t *svars, int t ) } } - // This is just an optimization, so it needs no journaling of intermediate states. - // However, doing it before the entry purge would require ensuring that the - // exception list includes all relevant messages. - if (svars->maxxfuid != svars->oldmaxxfuid) - JLOG( "! %u", svars->maxxfuid, "max expired UID on far side" ); - save_state( svars ); sync_bail( svars ); diff --git a/src/sync_p.h b/src/sync_p.h @@ -61,7 +61,6 @@ typedef struct { uint newuidval[2]; // UID validity obtained from driver uint finduid[2]; // TUID lookup makes sense only for UIDs >= this uint maxxfuid; // highest expired UID on far side - uint oldmaxxfuid; // highest expired UID on far side before this run uchar good_flags[2], bad_flags[2]; } sync_vars_t; diff --git a/src/sync_state.c b/src/sync_state.c @@ -286,9 +286,6 @@ load_state( sync_vars_t *svars ) tn = 0; bad = (sscanf( buf + 2, "%u %u %n", &t1, &t2, &tn ) < 2) || !tn || (ll - (uint)tn != TUIDL + 2); break; - case '!': - bad = sscanf( buf + 2, "%u", &t1 ) != 1; - break; case 'N': case 'F': case 'T': @@ -324,8 +321,6 @@ load_state( sync_vars_t *svars ) svars->finduid[t1] = t2; } else if (c == 'T') { *uint_array_append( &svars->trashed_msgs[t1] ) = t2; - } else if (c == '!') { - svars->maxxfuid = t1; } else if (c == '|') { svars->uidval[F] = t1; svars->uidval[N] = t2; @@ -387,6 +382,8 @@ load_state( sync_vars_t *svars ) break; case '~': srec->status = (srec->status & ~S_LOGGED) | t3; + if ((srec->status & S_EXPIRED) && svars->maxxfuid < srec->uid[F]) + svars->maxxfuid = srec->uid[F]; debug( "status now %#x\n", srec->status ); break; case '_':