jeff (02/23/83)
There is apparently a race condition in mail(1) wherein 2 simultaneous mailings to one person to become snarled or lost. I have two shell scripts which run in parallel and finish by mailing me their results. Unfortunately, the UNIX scheduler is so equanimous that the two scripts complete within one second of each other. The result? Sometimes both mailings are received. Sometimes just one. And now I just received the definitive piece of junk mail - one message comprising both files. They were interleaved in chunks of 2048 bytes (interesting, no?). Unfortunately, the total was less than the sum of the parts. About half of each file disappeared into the ether. Jeff Stearns ...!decvax!microsoft!fluke!jeff John Fluke Mfg. Co., Everett WA. (206) 356-5064 BTW, we run 4.1BSD.
mjb (02/23/83)
Re: a bug in mailing on 4.1BSD where simultaneous mailings mung the mailbox.
I had complaints of the same problem, although I had never seen it. I have had
no complaints after I made this fix to /usr/src/cmd/mail.c. You might also
want to increase the time before deciding a lock is dead if you are paranoid
(we upped it to 90 from 30, sometimes our system gets REAL SLOW).
.
.
.
send(n, name, fromaddr)
int n;
char *name;
char *fromaddr;
{
.
.
.
mask = umask(MAILMODE);
lock(file); /*BRUNIX*/
malf = fopen(file, "a");
umask(mask);
if (malf == NULL) {
unlock(); /*BRUNIX*/
fprintf(stdout, "mail: cannot append to %s\n", file);
return(0);
}
/***** lock(file); ****BRUNIX*/
.
-Mike Braca, Brown CS, ..!decvax!brunix!mjb, mjb.brown@udel-relay