From: Philipp Takacs Date: Wed, 18 Mar 2020 18:53:25 +0000 (+0100) Subject: seq_read and seq_list also recognise msg which don't exist X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=1980b87246c7099e9191890036398960f6dee4d1;p=mmh 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. --- 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" <