improve some debug messages

- print on which side we're upgrading a placeholder. as a side effect,
  this moves some magic out of upgrade_srec().
- don't use past tense for something that is only about to happen
- don't print status of every sync entry affected by journal replay -
  the entry load already prints it, and relevant operations print the
  new status. also, it was inconsistent with not printing the entry's
  old flags.
This commit is contained in:
Oswald Buddenhagen 2022-02-10 17:58:29 +01:00
parent 950ebe833d
commit 6e7b3d24c1
3 changed files with 11 additions and 11 deletions

View File

@ -1036,9 +1036,9 @@ box_loaded( int sts, message_t *msgs, int total_msgs, int recent_msgs, void *aux
// Consequently, the srec's flags are committed right away as well.
srec->flags = (srec->flags | srec->aflags[t]) & ~srec->dflags[t];
JLOG( "^ %u %u %u %u", (srec->uid[F], srec->uid[N], srec->pflags, srec->flags),
"upgrading placeholder, dummy's flags %s, srec flags %s",
(fmt_lone_flags( srec->pflags ).str, fmt_lone_flags( srec->flags ).str) );
nsrec = upgrade_srec( svars, srec );
"upgrading %s placeholder, dummy's flags %s, srec flags %s",
(str_fn[t], fmt_lone_flags( srec->pflags ).str, fmt_lone_flags( srec->flags ).str) );
nsrec = upgrade_srec( svars, srec, t );
}
}
// This is separated, because the upgrade can come from the journal.
@ -1199,7 +1199,7 @@ box_loaded( int sts, message_t *msgs, int total_msgs, int recent_msgs, void *aux
((srec->status & (S_EXPIRE|S_EXPIRED)) && (srec->msg[N]->flags & F_DELETED))) {
/* 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] );
debug( " expiring pair(%u,%u)\n", srec->uid[F], srec->uid[N] );
todel--;
}
}

View File

@ -95,4 +95,4 @@ void assign_uid( sync_vars_t *svars, sync_rec_t *srec, int t, uint uid );
void assign_tuid( sync_vars_t *svars, sync_rec_t *srec );
int match_tuids( sync_vars_t *svars, int t, message_t *msgs );
sync_rec_t *upgrade_srec( sync_vars_t *svars, sync_rec_t *srec );
sync_rec_t *upgrade_srec( sync_vars_t *svars, sync_rec_t *srec, int t );

View File

@ -344,7 +344,7 @@ load_state( sync_vars_t *svars )
error( "Error: journal entry at %s:%d refers to non-existing sync state entry\n", svars->jname, line );
goto jbail;
syncfnd:
debugn( " entry(%u,%u,%u) ", srec->uid[F], srec->uid[N], srec->flags );
debugn( " entry(%u,%u) ", srec->uid[F], srec->uid[N] );
switch (c) {
case '-':
debug( "killed\n" );
@ -392,11 +392,12 @@ load_state( sync_vars_t *svars )
srec->status = S_PENDING | (!srec->uid[F] ? S_DUMMY(F) : S_DUMMY(N));
break;
case '^':
tn = (srec->status & S_DUMMY(F)) ? F : N;
srec->pflags = (uchar)t3;
srec->flags = (uchar)t4;
debug( "is being upgraded, dummy's flags %s, srec flags %s\n",
fmt_lone_flags( t3 ).str, fmt_lone_flags( t4 ).str );
srec = upgrade_srec( svars, srec );
debug( "upgrading %s placeholder, dummy's flags %s, srec flags %s\n",
str_fn[tn], fmt_lone_flags( t3 ).str, fmt_lone_flags( t4 ).str );
srec = upgrade_srec( svars, srec, tn );
break;
default:
assert( !"Unhandled journal entry" );
@ -564,7 +565,7 @@ match_tuids( sync_vars_t *svars, int t, message_t *msgs )
}
sync_rec_t *
upgrade_srec( sync_vars_t *svars, sync_rec_t *srec )
upgrade_srec( sync_vars_t *svars, sync_rec_t *srec, int t )
{
// Create an entry and append it to the current one.
sync_rec_t *nsrec = nfzalloc( sizeof(*nsrec) );
@ -574,7 +575,6 @@ upgrade_srec( sync_vars_t *svars, sync_rec_t *srec )
svars->srecadd = &nsrec->next;
svars->nsrecs++;
// Move the placeholder to the new entry.
int t = (srec->status & S_DUMMY(F)) ? F : N;
nsrec->uid[t] = srec->uid[t];
srec->uid[t] = 0;
if (srec->msg[t]) { // NULL during journal replay; is assigned later.