[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Policy wrt mail lockfile (section 4.3)

In article <m0wfM9t-000AiLC@liw.clinet.fi>, Lars Wirzenius <liw@iki.fi> wrote:
>> Publib uses the return value from the stat call, which
>> you're not supposed to do.  (I don't know why yet.)
>I check that the link count is two to see if I managed to create
>the lock file with link(2). If the stat fails, I can't check
>the link count. I _must_ check the return of the stat.

The link count is not guaranteed to be updated because of inode
caches etc. Really.. The only thing you can do is stat the original
file and the link, and compare dev/ino pairs. Only then you're sure
the link() call succeeded.

As I said before, the implementation in qpopper-2.2-4 is IMO correct.
Looking at the code now, I only see one problem and that is:

                /* Locks are invalid after 5 minutes. */
                if (now < st.st_ctime + 300)

It should really do 

                /* Locks are invalid after 5 minutes. */
		if ((fd  = open(lockfile, O_RDONLY)) >= 0) {
			(void)read(fd, 1, buf);
			fstat(fd, &st1);
			now = st1.st_atime;
		} else
                if (now < st.st_ctime + 300)

To compensate for when the clocks of the 2 systems are out of sync.

| Miquel van Smoorenburg |  "I need more space" "Well, why not move to Texas" |
| miquels@cistron.nl     |  "No, on my account, stupid." "Stupid? Uh-oh.."    |
|     PGP fingerprint: FE 66 52 4F CD 59 A5 36  7F 39 8B 20 F1 D6 74 02       |

TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-devel-request@lists.debian.org . 
Trouble?  e-mail to templin@bucknell.edu .

Reply to: