rnews: batch naming and locking

Miquel van Smoorenburg miquels at cistron.nl
Tue Oct 22 09:39:31 UTC 2002



According to Alex Kiernan:
> > On one of our servers multiple rnews -U processes were running at
> > the same time, and because rnews doesn't lock the batch it's
> > processing this resulted in the same posting getting submitted
> > to innd multiple times. Innd rejected the duplicates, and they
> > ended up in the bad/ directory filling up the disk.
> > 
> Applied - sorry about the delay :(

The patch is not completely working though. The fixes are correct,
but the locking still has a race condition.

This is caused by the *stupid* POSIX fcntl() locking rules.

One of the rules state that 'upon a close(), all locks are
released' and that is taken literally.

That means:

fd = open(file);
fcntl(file, LOCK);
fd2 = dup(fd);
close (fd2); // here the lock is GONE

.. and that is exactly what the code does, the fd is dup()ed because
it is used with fdopen() which has to be closed later on to prevent
leaking FILE structs. Urgh.

I haven't seen an easy solution yet.

Mike.


More information about the inn-patches mailing list