Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!husc6!hao!ames!ucbcad!ucbvax!hplabs!hplabsb!davis From: davis@hplabsb.UUCP Newsgroups: comp.mail.elm Subject: Re: Elm for 4.3BSD? Message-ID: <4362@hplabsb.UUCP> Date: Thu, 22-Oct-87 16:09:08 EST Article-I.D.: hplabsb.4362 Posted: Thu Oct 22 16:09:08 1987 Date-Received: Sun, 25-Oct-87 06:56:35 EST References: <1355@ttidca.TTI.COM> Reply-To: davis@hplabsb.UUCP (Jim Davis) Organization: DataBase Technology Department, HP Labs, Palo Alto, CA Lines: 42 Keywords: Elm 1.7 flock/lockf versus creat/open locking Summary: lock() and unlock() in leavembox.c should be altered for flock() or lockf() style locking In article <1355@ttidca.TTI.COM> mb@ttidca.UUCP (Michael Bloom) writes: mb> Has anyone modified ELM to use flock(2) instead of lock files? mb> . . . but can't safely install it on the 4.3 systems at work. mb> Why? Because 4.3 uses flock instead of lock files for mail file mb> locking . . . the locking code in elm is scattered and mb> is used on files that are closed in some places, open in others. mb> flock only works on open file descriptors, and the combinations of mb> locking via lock files, opens and closes in the elm code do not lend mb> themselves to simple replacement with flock style locking. Skill is a reasonable requirement from the author of Elm, but clairvoyance seems to be too much to ask for. At the time that Elm was written, the mailbox locking protocols didn't use flock() or lockf(). Elm made an attempt to use a reasonably compatible protocol. I say that because Sys V /bin/mail and Sys V mailx have different, incompatible (subtly so) protocols. Sys V mailx and BSD 4.2 mail have the same protocol, but it times out far too quickly. I speak here as one who has had system mailboxes trashed over a dozen times. Elm's mailbox locking code seems to be in lock() and unlock() in src/leavembox.c. filter/actions.c has inline "creat" mailbox locking code. There is also locking code in utils/arepdaemon.c but not for locking mailboxes. Thus it looks like Elm's mailbox locking code is in but two places (one too many). As for its neglect to always hold open the mailbox, that would be an error. To use flock() (or lockf()) style locking, you should make sure that Elm holds the mailbox file open for the minimal time period. As a "brute force" solution to the problem you face, why not modify the lock() routine in Elm to open the mailbox (*again*) and flock() it, then modify the unlock() routine to un-flock() it and close the redundant open? No I haven't implemented the above, but that's because I don't have source to all of my other mailers. They use (various) lockfile locking protocols, so Elm had better not use lockf() for me. -- Jim ---------------------------------- Jim Davis (James W Davis) Email: {any_of_the_biggies} !hplabs!davis Arpa/Domain: davis@hplabs.hp.com ----------------------------------