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.
This commit is contained in:
Oswald Buddenhagen 2021-12-10 20:56:36 +01:00
parent 0f6362f2e2
commit 61b08880c8
3 changed files with 4 additions and 15 deletions

View File

@ -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 );

View File

@ -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;

View File

@ -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 '_':