make message counting in expiration code less confusing
This commit is contained in:
parent
83b834cdfd
commit
014d9b9081
18
src/sync.c
18
src/sync.c
|
@ -1067,7 +1067,7 @@ box_loaded( int sts, void *aux )
|
||||||
message_t *tmsg;
|
message_t *tmsg;
|
||||||
copy_vars_t *cv;
|
copy_vars_t *cv;
|
||||||
flag_vars_t *fv;
|
flag_vars_t *fv;
|
||||||
int uid, minwuid, *mexcs, nmexcs, rmexcs, no[2], del[2], todel, t1, t2;
|
int uid, minwuid, *mexcs, nmexcs, rmexcs, no[2], del[2], alive, todel, t1, t2;
|
||||||
int sflags, nflags, aflags, dflags, nex;
|
int sflags, nflags, aflags, dflags, nex;
|
||||||
unsigned hashsz, idx;
|
unsigned hashsz, idx;
|
||||||
char fbuf[16]; /* enlarge when support for keywords is added */
|
char fbuf[16]; /* enlarge when support for keywords is added */
|
||||||
|
@ -1356,17 +1356,21 @@ box_loaded( int sts, void *aux )
|
||||||
/* Note: When this branch is entered, we have loaded all slave messages. */
|
/* Note: When this branch is entered, we have loaded all slave messages. */
|
||||||
/* Expire excess messages. Important (flagged, unread, or unpropagated) messages
|
/* Expire excess messages. Important (flagged, unread, or unpropagated) messages
|
||||||
* older than the first not expired message are not counted towards the total. */
|
* older than the first not expired message are not counted towards the total. */
|
||||||
todel = svars->ctx[S]->count + svars->new_total[S] - svars->chan->max_messages;
|
debug( "preparing message expiration\n" );
|
||||||
debug( "%d excess messages on slave\n", todel );
|
alive = 0;
|
||||||
for (tmsg = svars->ctx[S]->msgs; tmsg && todel > 0; tmsg = tmsg->next) {
|
for (tmsg = svars->ctx[S]->msgs; tmsg; tmsg = tmsg->next) {
|
||||||
if (tmsg->status & M_DEAD)
|
if (tmsg->status & M_DEAD)
|
||||||
continue;
|
continue;
|
||||||
if ((srec = tmsg->srec) && srec->uid[M] > 0 &&
|
if ((srec = tmsg->srec) && srec->uid[M] > 0 &&
|
||||||
((tmsg->flags | srec->aflags[S]) & ~srec->dflags[S] & F_DELETED) &&
|
((tmsg->flags | srec->aflags[S]) & ~srec->dflags[S] & F_DELETED) &&
|
||||||
!(srec->status & (S_EXPIRE|S_EXPIRED)))
|
!(srec->status & (S_EXPIRE|S_EXPIRED))) {
|
||||||
todel--;
|
/* Message was not propagated yet, or is deleted. */
|
||||||
|
} else {
|
||||||
|
alive++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
debug( "... of which %d are not deleted\n", todel );
|
todel = alive - svars->chan->max_messages;
|
||||||
|
debug( "%d alive messages, %d excess - expiring\n", alive, todel );
|
||||||
for (tmsg = svars->ctx[S]->msgs; tmsg; tmsg = tmsg->next) {
|
for (tmsg = svars->ctx[S]->msgs; tmsg; tmsg = tmsg->next) {
|
||||||
if (tmsg->status & M_DEAD)
|
if (tmsg->status & M_DEAD)
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user