[news.software.b] locking in inews

jaap@kunivv1.sci.kun.nl (Jaap Bril) (07/26/88)

Finding a extremely large queue on our news-system I discovered a dead-lock.
As the comment in the code did not mention the other program by name, I did
some trial and error.
The following hack had inews exiting on EWOULDBLOCK about ten times and then
doing its job.
** Code from ifuncs.c (news_2.11)
** /*
**  * Newsystem locking.
**  */
** 
** #if defined(BSD4_2) || defined(LOCKF)
** #ifdef LOCKF
** #include <unistd.h>
** #else /* !LOCKF */
** #include <sys/file.h>
** #endif /* !LOCKF */
** static int LockFd = -1;
** lock()
** {
** 	LockFd = open(SUBFILE, 2);
** 	if (LockFd < 0)
** 		logerr("Can't open(%s,2) to lock", SUBFILE);
** 	/* This will sleep until the other program releases the lock */
** 	/* We may need to alarm out of this, but I don't think so */
** #ifdef LOCKF
** 	if (lockf(LockFd, F_LOCK, 0) < 0)
** #else
** /* added LOCK_NB JBCH */
** 	 if (flock(LockFd, LOCK_EX|LOCK_NB ) < 0)
**	                          ^^^^^^^^
** #endif
** 		xerror("Can't get lock on %s: %s", SUBFILE, errmsg(errno));
** }
** 
** unlock()
** {
** 	(void) close(LockFd);
** }
** #else /* !BSD4_2 */

Inews has been taking care of the backlog now for about a full day
(being restarted when I got tired of the messages) and has not exited again.
Could someone please enlighten me on the following points:

1. which is the other program?
2. why a lock in the first place?
3. can I safely assume inews is now processing correctly?

As I can't determine the importance (stupidity ?) of the question please
email or followup as appropriate.
-- 
*Jaap Bril                                 * mcvax!kunivv1!jaap               * 
*computer&communicatie zaken               *                                  *
*faculteit wiskunde en natuurwetenschappen *                                  *
*KU Nijmegen, The Netherlands              *                                  *

piet@cwi.nl (Piet Beertema) (08/03/88)

In article <4389.8807301843@tanna.cs.glasgow.ac.uk> taylor@cs.glasgow.ac.uk
(Jem Taylor) writes:
	Apparently 'kunivv1.sci.kun.nl' is not (yet?) a valid domain name.

That's right. They have been warned already and asked explicitly
to refrain from such nonsense.
Unfortunately I'm not aware of any access control feature in the
news system that would enable me to refuse messages with an invalid
address (at least as far as it can can be checked; and that's the
case for the whole .nl domain, for which mcvax is the entry point).
Or have I missed something?

-- 
---
Opinions expressed above reflect those of my employer, except when they don't

	Piet Beertema, CWI, Amsterdam	(piet@cwi.nl)

john@jetson.UUCP (John Owens) (08/03/88)

> Apparently 'kunivv1.sci.kun.nl' is not (yet?) a valid domain name.
I had the same problem.

> Maybe "the other program" is a concurrent invocation of inews ?
Or, more importantly, expire, which would get quite confused if the
active file were changed while it was running.  (It would, I think,
write back what it thought the active file should be, removing any
record of new articles, or, worse, newly created/removed groups.  The
history dbm database would be similarly munged by simultaneous
changes.)

-- 
John Owens		john@jetson.UPMA.MD.US
SMART HOUSE L.P.	uunet!jetson!john		(old uucp)
+1 301 249 6000		john%jetson.uucp@uunet.uu.net	(old internet)