From 1980b87246c7099e9191890036398960f6dee4d1 Mon Sep 17 00:00:00 2001 From: Philipp Takacs Date: Wed, 18 Mar 2020 19:53:25 +0100 Subject: [PATCH] seq_read and seq_list also recognise msg which don't exist This allows better handling of raceconditions, like a new mail gets deliverd while a unreed mail is shown. --- sbr/seq_list.c | 12 ++++-------- sbr/seq_read.c | 9 +++++++-- test/tests/show/test-unseen-update | 13 ++++++++++--- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/sbr/seq_list.c b/sbr/seq_list.c index 3606f6f..ce23c22 100644 --- a/sbr/seq_list.c +++ b/sbr/seq_list.c @@ -54,12 +54,9 @@ seq_list(struct msgs *mp, char *seqname) bp = buffer; - for (i = mp->lowmsg; i <= mp->hghmsg; ++i) { - /* - ** If message doesn't exist, or isn't in - ** the sequence, then continue. - */ - if (!does_exist(mp, i) || !in_sequence(mp, seqnum, i)) + for (i = mp->lowoff; i <= mp->hghoff; ++i) { + /* If message isn't in the sequence, then continue */ + if (!in_sequence(mp, seqnum, i)) continue; /* @@ -91,8 +88,7 @@ seq_list(struct msgs *mp, char *seqname) /* ** Scan to the end of this message range */ - for (++i; i <= mp->hghmsg && does_exist(mp, i) && - in_sequence(mp, seqnum, i); ++i) + for (++i; i <= mp->hghoff && in_sequence(mp, seqnum, i); ++i) ; if (i - j > 1) { diff --git a/sbr/seq_read.c b/sbr/seq_read.c index 041f632..4cc4223 100644 --- a/sbr/seq_read.c +++ b/sbr/seq_read.c @@ -210,9 +210,14 @@ seq_init(struct msgs *mp, char *name, char *field) ** We iterate through messages in this range ** and flip on bit for this sequence. */ + if (k > mp->hghoff) { + if (!(mp = folder_realloc(mp, mp->lowoff, k))) { + adios(EX_OSERR, NULL, "unable to allocate folder storage"); + } + mp->hghoff = k; + } for (; j <= k; j++) { - if (j >= mp->lowmsg && j <= mp->hghmsg && - does_exist(mp, j)) + if (j >= mp->lowmsg && j <= mp->hghoff) add_sequence(mp, i, j); } } diff --git a/test/tests/show/test-unseen-update b/test/tests/show/test-unseen-update index a4875c4..61e317e 100644 --- a/test/tests/show/test-unseen-update +++ b/test/tests/show/test-unseen-update @@ -24,7 +24,14 @@ runandcheck "pick u" <