ref: 90ad2b70ea5e6002adef90156c02881ef42927f4
parent: 5d357160775432816ceb80bfabc98375f7db73a5
author: Ori Bernstein <ori@eigenstate.org>
date: Thu Nov 19 12:38:48 EST 2020
mbox view: eliminate load/notify race, warp cursor on reopen When a message comes in as we're loading a mailbox, we can load it twice: once when scanning the directory, and the other from the seemail plumb message. This deduplicates on the name of the message being loaded (not the digest, so that we get acutal duplicates). Also, return mail messages if we fail to open a window, so that acme will warp the cursor to the open message.
--- a/mbox.c
+++ b/mbox.c
@@ -361,8 +361,16 @@
free(m);
m = p;
- }else
+ }else{
+ /*
+ * if we raced a notify and a mailbox load, we
+ * can get duplicate load requests for the same
+ * name in the mailbox.
+ */
+ if(p != nil && strcmp(p->name, m->name) == 0)
+ goto error;
addmesg(m, ins);
+ }
if(!threadsort || m->inreplyto == nil){
m->state |= Stoplev;
@@ -770,9 +778,9 @@
case 'l':
case 'L':
if(matchmesg(&mbox, ev->text))
- mesgopen(ev->text, nil);
- else
- winreturn(&mbox, ev);
+ if(mesgopen(ev->text, nil) != nil)
+ break;
+ winreturn(&mbox, ev);
break;
case 'x':
case 'X':