[1894] in testers
decmips: zmailnotify misbehaving
daemon@ATHENA.MIT.EDU (epeisach@Athena.MIT.EDU)
Sun May 17 16:46:15 1992
From: epeisach@Athena.MIT.EDU
Date: Sun, 17 May 92 16:46:01 -0400
To: testers@Athena.MIT.EDU
Cc: lwvanels@Athena.MIT.EDU, ckclark@Athena.MIT.EDU
zmailnotify used to only display new mail that you had not been notified
about previously. Now it displays all you new mail.
To see:
If you have mail from several different people, and you type
zmailnotify, you get the full list each time.
Run against the old version to see what I mean. The .maillock file is
updated properly.
The problem was in calvin's patch for POSIX_SOURCE locking. He changed
the open of the lockfile from "r" to "w" which is required for POSIX.
(If you are going to write lock a region, the file needs to be open for
write). Unforunately, the file also needs to be open for read to
determine one's place in the file. The following patch fixes this:
(Calvun's original patch changed the "r" to "w" and I make it "r+" which
opens for r/w and positions at beginning of file. A race condition still
exists after unlinking a creating the new file, but it's no worse than
before. (We could in theory rewind the file, write over the data and
then unlock)
Ezra
RCS file: RCS/zmailnotify.c,v
retrieving revision 1.1
diff -c -r1.1 zmailnotify.c
*** /tmp/,RCSt1a05230 Sun May 17 16:42:05 1992
--- zmailnotify.c Sun May 17 16:41:52 1992
***************
*** 121,127 ****
exit(1);
}
! lock = fopen(lockfile,"w");
#ifdef _POSIX_SOURCE
if (lock) {
struct flock fl;
--- 121,127 ----
exit(1);
}
! lock = fopen(lockfile,"r+");
#ifdef _POSIX_SOURCE
if (lock) {
struct flock fl;