commit 61b08880c8de61a42897f4680b36cded02dc9e8b
Author: Oswald Buddenhagen <o...@users.sf.net>
Date:   Fri Dec 10 20:56:36 2021 +0100

    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.

 src/sync.c       | 11 ++---------
 src/sync_p.h     |  1 -
 src/sync_state.c |  7 ++-----
 3 files changed, 4 insertions(+), 15 deletions(-)

diff --git a/src/sync.c b/src/sync.c
index bc379ea3..7be1212f 100644
--- a/src/sync.c
+++ b/src/sync.c
@@ -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 );
diff --git a/src/sync_p.h b/src/sync_p.h
index 704c10ce..1c001e23 100644
--- a/src/sync_p.h
+++ b/src/sync_p.h
@@ -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;
 
diff --git a/src/sync_state.c b/src/sync_state.c
index 2d3f5333..5c7f1146 100644
--- a/src/sync_state.c
+++ b/src/sync_state.c
@@ -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 '_':


_______________________________________________
isync-devel mailing list
isync-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/isync-devel

Reply via email to