🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #22529

Re: Reliable on-spool NoCeM canceller...

#22529
From: Rahul Dhesi
Date: Tue, 21 Oct 1997 00:00
143 lines
5059 bytes
In <62ivg1$feu$1@ramp2.tir.com> "Scott Gifford" <sgifford@tir.com> writes:

>  I'd like to start processing NoCeM "Hide" messages on our news spool, but
>all of the information I've been able to find about on-spool NoCeM
>cancellers has dire warnings about trashing your history file if INN is
>paused or throttled when it tries to hide an article, or of getting so
>behind as to be completely useless.

I had problems with ncmspool but c-nocem worked well (with slight
modifications).  My diffs are below, in case anybody is interested.
Partly cosmetic, partly to suppress perl warnings, partly to avoid being
killed by random signals, and partly to cause processing to be done very
N minutes rather than every N batches.

You can get both ncmspool and c-nocem by following the
links at http://www.cm.org/ .

--- 1.1	1997/08/23 17:09:03
+++ c-nocem	1997/08/27 07:55:08
@@ -1,9 +1,9 @@
-#!/usr/bin/perl
+#! /etc/LOCAL/bin/perl5.003
 
 # NoCeM in the spool for C News and INN - grand unified program
 # Written by Olaf Titz <olaf@bigred.inka.de>, May-Aug 1997.
 # This program is in the public domain.
-$ID='$Id: c-nocem,v 1.1 1997/08/23 17:09:03 dhesi Exp $';
+$ID='$Id: c-nocem,v 1.8 1997/08/27 07:50:44 dhesi Exp $';
 
 # For C News:
 # set up a batched feed like this:
@@ -22,8 +22,9 @@
 # ----------------------------------------------------------------------------
 # Configuration
 
-$newsctl="/var/lib/news";
-$newsarts="/var/spool/news";
+$newsctl="/news/lib";
+$log = '/news/inn/log/c-nocem.log';
+$newsarts="/news/news";
 
 $pubring="$newsctl/ncmring.pgp";
 $perm="$newsctl/ncmperm";
@@ -31,7 +32,7 @@
 $tmp="$newsctl/tmp"; # create this directory, do not use world writable /tmp
 $batchfile="$tmp/noc.batch";
 
-$ENV{'PATH'}="/bin:/usr/local/bin:/usr/bin:$newsctl/bin:$newsctl/localbin";
+$ENV{'PATH'}="/news/bin:/bin";
 $ENV{'PGPPATH'}="$newsctl/.pgp";
 # ----------------------------------------------------------------------------
 
@@ -43,6 +44,10 @@
 undef $opt_s if ($opt_n);
 if ($opt_s) {
     open(STDOUT, ">/dev/null") || die "open /dev/null: $!";
+} else {
+   # don't write to stdout -- it causes us to get SIGTTOU
+   open(STDOUT, ">/tmp/c-nocem.log");
+   open(STDERR, ">&STDOUT");
 }
 select STDOUT; $|=1;
 @Month=("Jan", "Feb", "Mar", "Apr", "May", "Jun",
@@ -57,10 +62,10 @@
     $del_one=21600/$opt_d;
     $del_run=$del_one*3/2;
 }
-$LOCK_SH = 1;
+## $LOCK_SH = 1;
 $LOCK_EX = 2;
-$LOCK_NB = 4;
-$LOCK_UN = 8;
+## $LOCK_NB = 4;
+## $LOCK_UN = 8;
 
 $groupcheck="";
 if (-f $groups) {
@@ -96,18 +101,26 @@
 $SIG{"HUP"}="shutdown";
 $SIG{"TERM"}="shutdown";
 $SIG{"INT"}="shutdown";
-print "Starting $ID\n\n" unless ($opt_s);
+$SIG{"PIPE"}="shutdown";
+$SIG{"TTOU"}="DEFAULT";
+my $timenow = scalar localtime(time);
+print "$timenow\nStarting [$$]\n$ID\n\n" unless ($opt_s);
+$lastruntime = time;		# time of last batch run aka &deletethem
+$TIME_WAIT = 15 * 60;		# wait this many seconds between batch runs
 # Read the notice(s)
 if ($opt_b || $opt_c) {
     while ($file=<STDIN>, defined($file)) {
 	sleep $del_run;
 	@_=split(/[ \t\r\n]+/, $file); $file=$_[0];
-	print STDOUT "File $file:\n" unless ($opt_s);
+	$timenow = scalar localtime(time);
+	$opt_s || print STDOUT "$timenow\n$file\n";
 	&procfile("<$file");
 	print STDOUT "\n" unless ($opt_s);
-	if (--$m<0) {
+	if (--$m<0 || ((time - $lastruntime) > $TIME_WAIT)) {
+	    # if read $opt_c filenames
 	    &deletethem;
 	    $m=($opt_c?$opt_c:99999999);
+	    $lastruntime = time;		# remember time of batch run
 	}
     }
 } else {
@@ -161,7 +174,7 @@
 	$SIG{"HUP"}="finish";
 	$SIG{"TERM"}="finish";
 	$SIG{"INT"}="finish";
-	open(C, "$groupcheck|fastcancel -lci -f '$lf' >>$newsctl/log")
+	open(C, "$groupcheck|fastcancel -lci -f '$lf' >> $log 2>&1")
 	    || die "invoke fastcancel: $!";
     }
     $i=0;
@@ -199,8 +212,7 @@
     if (!$pid) {
 	open(STDERR, ">&EW");
 	close(ER);
-	exec "pgp -f $pgpargs $f >$tf";
-	exit 99;
+	exec "pgp -f $pgpargs $f >$tf" || exit 99;
     }
     undef $s; undef $u;
     close(EW);
@@ -361,6 +373,10 @@
 sub shutdown
 {
     local($s)=@_;
+    # ignore any more SIGPIPE,
+    # but die on SIGTTOU
+    $SIG{'PIPE'} = 'IGNORE';
+    $SIG{'TTOU'} = 'DEFAULT';
     if ($s) {
 	print STDOUT "SIG$s\n";
     }

-- 
Rahul Dhesi <dhesi@spams.r.us.com>

Technical Details
Message-ID: <62j3hf$78$1@samba.rahul.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
References: <62ivg1$feu$1@ramp2.tir.com>

Show Full Headers
Complete Article Headers
Message-ID: <62j3hf$78$1@samba.rahul.net>
Subject: Re: Reliable on-spool NoCeM canceller...
Date: Tue, 21 Oct 1997 00:00:00 +0000
From: c.c.eiftj@64.usenet.us.com (Rahul Dhesi)
References: <62ivg1$feu$1@ramp2.tir.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
X-Deja-AN: 282264563
Organization: a2i network
X-Comment: Encoded From: line allows replies that preserve original subject
NNTP-Posting-User: dhesi
Newsgroups: news.software.nntp