isync

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

commit 7f784fd23597e146c035a51e4256be8a1d923824
parent 8b76412b0d16bac8ba9696ddd4563968cc9eab0f
Author: Oswald Buddenhagen <ossi@users.sf.net>
Date:   Sat,  2 Nov 2013 20:47:20 +0100

log maxuid bumping less aggressively

we can bump the internal variable whereever convenient, but we cannot
log it until we know that all messages were copied, as otherwise we
could miss some new messages after an interruption. with the new
approach, interruption would merely cause some additonal traffic.

Diffstat:
Msrc/sync.c | 12++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/sync.c b/src/sync.c @@ -1224,6 +1224,12 @@ box_loaded( int sts, void *aux ) Fprintf( svars->jfp, "+ %d %d\n", srec->uid[M], srec->uid[S] ); debug( " -> pair(%d,%d) created\n", srec->uid[M], srec->uid[S] ); } + if (svars->maxuid[1-t] < tmsg->uid) { + /* We do this here for simplicity. However, logging must be delayed until + * all messages were propagated, as skipped messages could otherwise be + * logged before the propagation of messages with lower UIDs completes. */ + svars->maxuid[1-t] = tmsg->uid; + } if ((tmsg->flags & F_FLAGGED) || tmsg->size <= svars->chan->stores[t]->max_size) { if (tmsg->flags) { srec->flags = tmsg->flags; @@ -1502,10 +1508,6 @@ msg_copied_p2( sync_vars_t *svars, sync_rec_t *srec, int t, message_t *tmsg, int } if (!tmsg->srec) { tmsg->srec = srec; - if (svars->maxuid[1-t] < tmsg->uid) { - svars->maxuid[1-t] = tmsg->uid; - Fprintf( svars->jfp, "%c %d\n", ")("[t], tmsg->uid ); - } } } @@ -1519,6 +1521,8 @@ msgs_copied( sync_vars_t *svars, int t ) if (!(svars->state[t] & ST_SENT_NEW) || svars->new_done[t] < svars->new_total[t]) return; + Fprintf( svars->jfp, "%c %d\n", ")("[t], svars->maxuid[1-t] ); + if (svars->state[t] & ST_FIND_NEW) { debug( "finding just copied messages on %s\n", str_ms[t] ); svars->drv[t]->find_new_msgs( svars->ctx[t], msgs_found_new, AUX );