Path: utzoo!utgpu!attcan!uunet!mcvax!kunivv1!jaap From: jaap@kunivv1.sci.kun.nl (Jaap Bril) Newsgroups: news.software.b Subject: locking in inews (2.11) Keywords: inews locking Message-ID: <257@kunivv1.sci.kun.nl> Date: 26 Jul 88 14:42:19 GMT Organization: University of Nijmegen, The Netherlands. Lines: 56 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 ** #else /* !LOCKF */ ** #include ** #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 * *