commit 5a21042e980a4697623eaf5614a1dad0e6fdee23
Author: Oswald Buddenhagen <o...@users.sf.net>
Date:   Wed Dec 11 16:25:30 2013 +0100

    ensure sequencing of message propagation and store closing
    
    by putting the message propagation last, d3f634702 uncovered a
    long-standing problem: we might have closed the source store before all
    messages were propagated from it.

 src/sync.c |   17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/sync.c b/src/sync.c
index 94b3fb7..957188c 100644
--- a/src/sync.c
+++ b/src/sync.c
@@ -204,6 +204,7 @@ static int check_cancel( sync_vars_t *svars );
 #define ST_CANCELED        (1<<9)
 #define ST_SELECTED        (1<<10)
 #define ST_DID_EXPUNGE     (1<<11)
+#define ST_CLOSING         (1<<12)
 
 
 static void
@@ -1594,7 +1595,12 @@ msgs_copied( sync_vars_t *svars, int t )
        if (!(svars->state[t] & ST_SENT_NEW) || svars->new_done[t] < 
svars->new_total[t])
                return;
 
+       sync_ref( svars );
+
        Fprintf( svars->jfp, "%c %d\n", ")("[t], svars->maxuid[1-t] );
+       sync_close( svars, 1-t );
+       if (check_cancel( svars ))
+               goto out;
 
        if (svars->state[t] & ST_FIND_NEW) {
                debug( "finding just copied messages on %s\n", str_ms[t] );
@@ -1602,6 +1608,9 @@ msgs_copied( sync_vars_t *svars, int t )
        } else {
                msgs_new_done( svars, t );
        }
+
+  out:
+       sync_deref( svars );
 }
 
 static void
@@ -1775,9 +1784,13 @@ static void box_closed_p2( sync_vars_t *svars, int t );
 static void
 sync_close( sync_vars_t *svars, int t )
 {
-       if ((~svars->state[t] & (ST_FOUND_NEW|ST_SENT_TRASH)) ||
-           svars->trash_done[t] < svars->trash_total[t])
+       if ((~svars->state[t] & (ST_FOUND_NEW|ST_SENT_TRASH)) || 
svars->trash_done[t] < svars->trash_total[t] ||
+           !(svars->state[1-t] & ST_SENT_NEW) || svars->new_done[1-t] < 
svars->new_total[1-t])
+               return;
+
+       if (svars->state[t] & ST_CLOSING)
                return;
+       svars->state[t] |= ST_CLOSING;
 
        if ((svars->chan->ops[t] & OP_EXPUNGE) /*&& !(svars->state[t] & 
ST_TRASH_BAD)*/) {
                debug( "expunging %s\n", str_ms[t] );

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
isync-devel mailing list
isync-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/isync-devel

Reply via email to