Hi [2019-12-15 17:55] Philipp Takacs <phil...@bureaucracy.de> > I have looked at the problem with open pager for show and change the > sequences during the pager is open. This happen often, if you show a > message and recieve a new message.
after a hint from simon, that in my patch is still a racecondition I have looked at it again and found the bug. A patch is attached. Explenation: seq_read and seq_list totaly ignore mails without the EXISTS flag. So when a new mail arrives during show has it's pager open, the seq_read will see the new unseen flag and ignores it. Because it doesn't know this mail exists. To avoid a total reread for some coner cases I belive it's better just to ignore, if a mail exists or not. comments? Philipp
From 9bf8d356af4e3a6ad57d7010b5088c85f91935f8 Mon Sep 17 00:00:00 2001 From: Philipp Takacs <phil...@bureaucracy.de> Date: Wed, 18 Mar 2020 19:53:25 +0100 Subject: [PATCH 3/3] 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 | 7 +++---- sbr/seq_read.c | 9 +++++++-- test/tests/show/test-unseen-update | 13 ++++++++++--- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/sbr/seq_list.c b/sbr/seq_list.c index 3606f6f3..65cc7aa0 100644 --- a/sbr/seq_list.c +++ b/sbr/seq_list.c @@ -54,12 +54,12 @@ seq_list(struct msgs *mp, char *seqname) bp = buffer; - for (i = mp->lowmsg; i <= mp->hghmsg; ++i) { + for (i = mp->lowmsg; i <= mp->hghoff; ++i) { /* ** If message doesn't exist, or isn't in ** the sequence, then continue. */ - if (!does_exist(mp, i) || !in_sequence(mp, seqnum, i)) + if (!in_sequence(mp, seqnum, i)) continue; /* @@ -91,8 +91,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 041f6327..4cc42233 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 a4875c43..61e317ed 100644 --- a/test/tests/show/test-unseen-update +++ b/test/tests/show/test-unseen-update @@ -24,7 +24,14 @@ runandcheck "pick u" <<! 8 9 ! -mark -sequence u -add -nozero 10 + +#add a new mail +rcvstore <<! +From: test +To: test + +testmail +! runandcheck "pick u" <<! 1 2 @@ -35,12 +42,12 @@ runandcheck "pick u" <<! 7 8 9 -10 +11 ! pkill -P $pagerpid wait $pagerpid runandcheck "pick u" <<! 9 -10 +11 ! -- 2.20.1