[news.software.nntp] Locking problem with C news and nntpsend

david@elroy.jpl.nasa.gov (07/20/89)

The nntpsend.{csh,sh} programs in the current nntp distribution do not
lock properly with C news relaynews.

Situation:
	Relaynews is running and it has opened up the batch files for
the out going systems.  Nntpsend starts up and finds that the batch
file is non-empty so it mv's it to host.nntp and fires up nntpxmit.
If nntpxmit finishes before relaynews does it will unlink host.nntp
which relaynews still has open and thus the articles not yet batched
will disappear.

This will effect sites that have nntpsend running at the same time as 
relaynews and especially those sites that run nntpsend once a minute.

My solution was to create a small shell program that did a newslock
on LOCK before doing the mv.  It was cloned after the batchsplit
shell script and is quite simple.  I called it "nntpmv" and replaced
the two calls to mv with it and it appears to solve the problem.

Someone mentioned reworking NNTP 1.5.5 to work and lock in the C news
way of doing things but I have not seen it distributed yet.

	-David Robinson
	david@elroy.jpl.nasa.gov
============
#! /bin/sh
# Move off NNTP batches
# nntpmv ifile ofile

# =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
. ${NEWSCONFIG-/usr/lib/news/bin/config}

PATH=$NEWSCTL/bin:$NEWSBIN/batch:$NEWSBIN:$NEWSPATH ; export PATH
umask $NEWSUMASK

# Locking.
lock="$NEWSCTL/LOCK"
ltemp="$NEWSCTL/L.$$"
echo $$ >$ltemp
trap "rm -f $ltemp ; exit 0" 0 1 2 15
while true
do
	if newslock $ltemp $lock
	then
		trap "rm -f $ltemp $lock ; exit 0" 0 1 2 15
		break
	fi
	sleep 10
done

if test -f $2
then
	exit 0
fi

mv $1 $2
==========
	David Robinson		elroy!david@csvax.caltech.edu     ARPA
				david@elroy.jpl.nasa.gov	  ARPA
				{cit-vax,ames}!elroy!david	  UUCP
Disclaimer: No one listens to me anyway!