home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!charon.amdahl.com!pacbell.com!decwrl!netsys!agate!ames!haven.umd.edu!darwin.sura.net!zaphod.mps.ohio-state.edu!cs.utexas.edu!qt.cs.utexas.edu!news.Brown.EDU!noc.near.net!seqp4!ajm
- From: ajm@seqp4.sequoia.com (A.J.Madison)
- Newsgroups: comp.mail.sendmail
- Subject: file locking after forks in sendmail 5.65
- Keywords: locking files in 5.65
- Message-ID: <1666@seqp4.sequoia.com>
- Date: 11 Nov 92 23:10:12 GMT
- Organization: Sequoia Systems Inc., Marlboro, Mass.
- Lines: 46
-
- I ran into a problem of recipients complaining of receiving 2 copies of the
- same mail. Careful examination of the headers and the syslogs led me to
- conclude that if a user had the misfortune of sending mail at the very
- instant the system's sendmail daemon woke up to check the queue, the mail
- would end up getting delivered twice.
-
- After reproducing the problem on a test machine, I realized that locking on
- queue files in the spool directory was not working on our system. We're
- SVR3.2 on the outside and fault tolerant & proprietary on the inside (which
- leaves the possibility the OS folks blew it).
-
- Further testing showed me that the reason that locking was not working was
- because during the delivery phase, sendmail locks the queue file, builds all
- the other things it needs to - like the body of the message, forks, closes
- the queue file and exits, leaving the child to complete final delivery.
- After the fork, the queue file is wide open to any process that wishes to
- lock it again, including the child. Reading the SVR3.2 manual page on fork,
- it explicitly states:
-
- The child process differs from the parent process in the
- following ways:
- ...
- Process locks, text locks and data locks are not
- inherited by the child [see plock(2)].
- ...
-
- By adding code to have the child (actually its the child of the child)
- re-lock the queue file, the locking is mostly preserved. If the child cannot
- lock the file, the daemon must have got there first. In any case, the files
- are in the spool directory, where they'll get sent eventually, hopefully.
-
- Has anyone else noticed this issue, especially when debugging a problem,
- and dealt with it? How about the BSD (and their ilk) folks. I don't have
- a fork manual page from a BSD system handy (probably should...) so I can
- only guess that BSD systems hand down file locks to children, which could
- be a real mess if both parent & child choose to write to the same file.
-
- I'm especially cursious what other bugs may be lurking in a sendmail ported
- V.3 or V.4, either becaues of this issue about locking across System V
- forks or anything else. (For instance I'm still not sure how much frozen
- configs are going to be tolerated by shared libraries.)
- --
- when everyone is out to get you, being paranoid is just good thinking.
- - Dr. Johnny Fever <in other words, standard disclaimer>
- A.J. Madison ajm@sequoia.com
- Sequoia Systems Inc.
-