Article View: news.software.nntp
Article #84507Re: The mailpost perl script from inn-2.5.3rc1.
From: Dennis Davis
Date: Thu, 17 Nov 2011 16:36
Date: Thu, 17 Nov 2011 16:36
70 lines
3011 bytes
3011 bytes
In article <ja1blc$13g$1@news.trigofacile.com>,
Julien ΓLIE <iulius@nom-de-mon-site.com.invalid> wrote:
...
>Instead of using a $locked variable, wouldn't it be better to add a
>INN::Utils::Shlock::releaselocks() function?
>
>INN::Utils::Shlock would then keep track of still used lock files during
>the run of a Perl script (through an array because several lock files
>can exist at the same time for a script).
>Then, it would be enough to add INN::Utils::Shlock::releaselocks() in an
>END section in all the Perl scripts using this module.
That's a much better idea. Why didn't I think of it :-(
The patches below are for INN::Utils::Shlock and are a quick
and dirty attempt to implement this functionality. I haven't
added anything to the manul page, although this does need a few
descriptive lines.
*** Shlock.pm.orig Wed Oct 26 09:48:33 2011
--- Shlock.pm Thu Nov 17 16:25:33 2011
***************
*** 15,21 ****
--- 15,23 ----
our @ISA = qw(Exporter);
our $VERSION = "$INN::Config::VERSION";
+ my %lockfiles;
+
##
## Returns true if the file is properly locked.
##
***************
*** 30,35 ****
--- 32,38 ----
while ($locktry < $lockretrymax) {
if (system("$INN::Config::newsbin/shlock", '-p', $$, '-f', $lockfile) == 0) {
+ $lockfiles{$lockfile} = 1;
return 1;
}
$locktry++;
***************
*** 49,54 ****
--- 52,69 ----
return unlink $lockfile;
}
+ ##
+ ## Attempt to unlock any leftover locks.
+ ##
+ sub releaselocks {
+ my $key;
+ foreach $key (keys(%lockfiles)) {
+ unlock($key);
+ }
+ undef(%lockfiles);
+ return 1;
+ }
+
## This array will contain what it is possible to export.
our @EXPORT_OK = qw(lock unlock);
--
Dennis Davis, BUCS, University of Bath, Bath, BA2 7AY, UK
D.H.Davis@bath.ac.uk
Technical Details
Message-ID:
<LutCsG.JCt.B.shoe@bath.ac.uk>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20141118.mbox.gz!num2.nntp.dca.giganews.com!num1.nntp.dca.giganews.com!number.nntp.dca.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!goblin1!goblin.stu.neva.ru!txtfeed2.tudelft.nl!tudelft.nl!txtfeed1.tudelft.nl!dedekind.zen.co.uk!zen.net.uk!hamilton.zen.co.uk!163.1.2.201.MISMATCH!feeds.news.ox.ac.uk!news.ox.ac.uk!bath.ac.uk!unknownReferences:
<LuC8By.M8s.B.shoe@bath.ac.uk> <ja1blc$13g$1@news.trigofacile.com>Show Full Headers
Complete Article Headers
Message-ID: <LutCsG.JCt.B.shoe@bath.ac.uk> Subject: Re: The mailpost perl script from inn-2.5.3rc1. Date: Thu, 17 Nov 2011 16:36:16 GMT From: Dennis Davis <D.H.Davis@bath.ac.uk> References: <LuC8By.M8s.B.shoe@bath.ac.uk> <ja1blc$13g$1@news.trigofacile.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.20141118.mbox.gz!num2.nntp.dca.giganews.com!num1.nntp.dca.giganews.com!number.nntp.dca.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!goblin1!goblin.stu.neva.ru!txtfeed2.tudelft.nl!tudelft.nl!txtfeed1.tudelft.nl!dedekind.zen.co.uk!zen.net.uk!hamilton.zen.co.uk!163.1.2.201.MISMATCH!feeds.news.ox.ac.uk!news.ox.ac.uk!bath.ac.uk!unknown Newsgroups: news.software.nntp X-Newsreader: trn 4.0-test77 (Sep 1, 2010) Sender: unknown@larch.bath.ac.uk (Address not verified) Organization: BUCS, University of Bath, UK Originator: ccsdhd@bath.ac.uk (Dennis Davis) Lines: 69