Browse Source

don't log right before saving state unless requested

only the journal replay autotest really needs it. in other cases it's
just wasting time and ssd life.
wip/maildir-path-under-inbox
Oswald Buddenhagen 3 years ago
parent
commit
698f9ff173
  1. 1
      src/common.h
  2. 3
      src/main.c
  3. 2
      src/run-tests.pl
  4. 8
      src/sync.c
  5. 17
      src/sync_p.h

1
src/common.h

@ -115,6 +115,7 @@ BIT_ENUM(
ZERODELAY, ZERODELAY,
KEEPJOURNAL, KEEPJOURNAL,
FORCEJOURNAL,
FORCEASYNC(2), FORCEASYNC(2),
) )

3
src/main.c

@ -438,6 +438,9 @@ main( int argc, char **argv )
case 'j': case 'j':
DFlags |= KEEPJOURNAL; DFlags |= KEEPJOURNAL;
break; break;
case 'J':
DFlags |= FORCEJOURNAL;
break;
case 's': case 's':
JLimit = strtol( ochar, &ochar, 10 ); JLimit = strtol( ochar, &ochar, 10 );
break; break;

2
src/run-tests.pl

@ -765,7 +765,7 @@ sub test_impl($$$$)
mkchan($sx); mkchan($sx);
my ($xc, $ret) = runsync($async, "-Tj", "1-initial.log"); my ($xc, $ret) = runsync($async, "-Tj -TJ", "1-initial.log");
my $rtx = readchan($$sx{state}) if (!$xc); my $rtx = readchan($$sx{state}) if (!$xc);
if ($xc || cmpchan($rtx, $tx)) { if ($xc || cmpchan($rtx, $tx)) {
print "Input:\n"; print "Input:\n";

8
src/sync.c

@ -1735,7 +1735,7 @@ box_closed_p2( sync_vars_t *svars, int t )
// of interruption - in particular skipping messages would otherwise // of interruption - in particular skipping messages would otherwise
// up the limit too early. // up the limit too early.
if (svars->maxuid[t] != svars->oldmaxuid[t]) if (svars->maxuid[t] != svars->oldmaxuid[t])
JLOG( "N %d %u", (t, svars->maxuid[t]), "up maxuid of %s", str_fn[t] ); PC_JLOG( "N %d %u", (t, svars->maxuid[t]), "up maxuid of %s", str_fn[t] );
} }
if (((svars->state[F] | svars->state[N]) & ST_DID_EXPUNGE) || svars->chan->max_messages) { if (((svars->state[F] | svars->state[N]) & ST_DID_EXPUNGE) || svars->chan->max_messages) {
@ -1746,14 +1746,14 @@ box_closed_p2( sync_vars_t *svars, int t )
if (!srec->uid[N] || ((srec->status & S_DEL(N)) && (svars->state[N] & ST_DID_EXPUNGE))) { if (!srec->uid[N] || ((srec->status & S_DEL(N)) && (svars->state[N] & ST_DID_EXPUNGE))) {
if (!srec->uid[F] || ((srec->status & S_DEL(F)) && (svars->state[F] & ST_DID_EXPUNGE)) || if (!srec->uid[F] || ((srec->status & S_DEL(F)) && (svars->state[F] & ST_DID_EXPUNGE)) ||
((srec->status & S_EXPIRED) && svars->maxuid[F] >= srec->uid[F] && svars->maxxfuid >= srec->uid[F])) { ((srec->status & S_EXPIRED) && svars->maxuid[F] >= srec->uid[F] && svars->maxxfuid >= srec->uid[F])) {
JLOG( "- %u %u", (srec->uid[F], srec->uid[N]), "killing" ); PC_JLOG( "- %u %u", (srec->uid[F], srec->uid[N]), "killing" );
srec->status = S_DEAD; srec->status = S_DEAD;
} else if (srec->uid[N]) { } else if (srec->uid[N]) {
JLOG( "> %u %u 0", (srec->uid[F], srec->uid[N]), "orphaning" ); PC_JLOG( "> %u %u 0", (srec->uid[F], srec->uid[N]), "orphaning" );
srec->uid[N] = 0; srec->uid[N] = 0;
} }
} else if (srec->uid[F] && ((srec->status & S_DEL(F)) && (svars->state[F] & ST_DID_EXPUNGE))) { } else if (srec->uid[F] && ((srec->status & S_DEL(F)) && (svars->state[F] & ST_DID_EXPUNGE))) {
JLOG( "< %u %u 0", (srec->uid[F], srec->uid[N]), "orphaning" ); PC_JLOG( "< %u %u 0", (srec->uid[F], srec->uid[N]), "orphaning" );
srec->uid[F] = 0; srec->uid[F] = 0;
} }
} }

17
src/sync_p.h

@ -72,17 +72,22 @@ void delete_state( sync_vars_t *svars );
void ATTR_PRINTFLIKE(2, 3) jFprintf( sync_vars_t *svars, const char *msg, ... ); void ATTR_PRINTFLIKE(2, 3) jFprintf( sync_vars_t *svars, const char *msg, ... );
#define JLOG_(log_fmt, log_args, dbg_fmt, ...) \ #define JLOG_(pre_commit, log_fmt, log_args, dbg_fmt, ...) \
do { \ do { \
if (pre_commit && !(DFlags & FORCEJOURNAL)) { \
debug( "-> (log: " log_fmt ") (" dbg_fmt ")\n", __VA_ARGS__ ); \
} else { \
debug( "-> log: " log_fmt " (" dbg_fmt ")\n", __VA_ARGS__ ); \ debug( "-> log: " log_fmt " (" dbg_fmt ")\n", __VA_ARGS__ ); \
jFprintf( svars, log_fmt "\n", deparen(log_args) ); \ jFprintf( svars, log_fmt "\n", deparen(log_args) ); \
} \
} while (0) } while (0)
#define JLOG3(log_fmt, log_args, dbg_fmt) \ #define JLOG3(pre_commit, log_fmt, log_args, dbg_fmt) \
JLOG_(log_fmt, log_args, dbg_fmt, deparen(log_args)) JLOG_(pre_commit, log_fmt, log_args, dbg_fmt, deparen(log_args))
#define JLOG4(log_fmt, log_args, dbg_fmt, dbg_args) \ #define JLOG4(pre_commit, log_fmt, log_args, dbg_fmt, dbg_args) \
JLOG_(log_fmt, log_args, dbg_fmt, deparen(log_args), deparen(dbg_args)) JLOG_(pre_commit, log_fmt, log_args, dbg_fmt, deparen(log_args), deparen(dbg_args))
#define JLOG_SEL(_1, _2, _3, _4, x, ...) x #define JLOG_SEL(_1, _2, _3, _4, x, ...) x
#define JLOG(...) JLOG_SEL(__VA_ARGS__, JLOG4, JLOG3, NO_JLOG2, NO_JLOG1)(__VA_ARGS__) #define JLOG(...) JLOG_SEL(__VA_ARGS__, JLOG4, JLOG3, NO_JLOG2, NO_JLOG1)(0, __VA_ARGS__)
#define PC_JLOG(...) JLOG_SEL(__VA_ARGS__, JLOG4, JLOG3, NO_JLOG2, NO_JLOG1)(1, __VA_ARGS__)
void assign_uid( sync_vars_t *svars, sync_rec_t *srec, int t, uint uid ); void assign_uid( sync_vars_t *svars, sync_rec_t *srec, int t, uint uid );

Loading…
Cancel
Save