Author: ranger
Date: Thu Feb 15 16:00:59 2007
New Revision: 653

URL: 
<http://svn.finkproject.org/websvn/listing.php?sc=1&rev=653&repname=user%3a+ranger>
Log:
add locking

Modified:
    trunk/experimental/scripts/mirror.pl
    trunk/experimental/scripts/rss-newpackages.pl

Modified: trunk/experimental/scripts/mirror.pl
URL: 
<http://svn.finkproject.org/websvn/diff.php?path=/trunk/experimental/scripts/mirror.pl&rev=653&repname=user%3a+ranger>
==============================================================================
--- trunk/experimental/scripts/mirror.pl (original)
+++ trunk/experimental/scripts/mirror.pl Thu Feb 15 16:00:59 2007
@@ -6,6 +6,7 @@
 use lib '/home/ranger/cvs/rangerrick/scripts';
 
 use Data::Dumper;
+use Fcntl qw(:DEFAULT :flock);
 use File::Copy;
 use File::Find;
 use File::Path;
@@ -13,6 +14,10 @@
 use Fink::Package;
 use Fink::PkgVersion;
 use Fink::Services qw(&find_subpackages);
+
+open (LOCKFILE, '>>/home/ranger/var/run/mirror.lock.lock') or die "could not 
open lockfile for append: $!";
+my $return = flock(LOCKFILE, LOCK_EX | LOCK_NB);
+die "another process is already running" if (not $return);
 
 use vars qw(
        $CVSROOT

Modified: trunk/experimental/scripts/rss-newpackages.pl
URL: 
<http://svn.finkproject.org/websvn/diff.php?path=/trunk/experimental/scripts/rss-newpackages.pl&rev=653&repname=user%3a+ranger>
==============================================================================
--- trunk/experimental/scripts/rss-newpackages.pl (original)
+++ trunk/experimental/scripts/rss-newpackages.pl Thu Feb 15 16:00:59 2007
@@ -6,23 +6,28 @@
 use lib '/home/ranger/cvs/rangerrick/scripts';
 
 use utf8;
+use Cwd qw(abs_path);
+use Data::Dumper;
 use Encode;
-use Data::Dumper;
-use Cwd qw(abs_path);
+use Fcntl qw(:DEFAULT :flock);
 use File::Basename;
 use File::Find;
 use File::MMagic;
-use XML::RSS;
-use Storable;
 use Fink::Package;
 use Fink::PkgVersion;
+use Storable;
 use Text::Wrap qw(fill $columns);
 use URI::Find;
+use XML::RSS;
 
 $columns = 76;
 
 #use utf8;
 use strict;
+
+open (LOCKFILE, '>>/home/ranger/var/run/rss-newpackages.lock') or die "could 
not open lockfile for append: $!";
+my $return = flock(LOCKFILE, LOCK_EX | LOCK_NB);
+die "another process is already running" if (not $return);
 
 use vars qw(
   $CUTOFF


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Fink-commits mailing list
Fink-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fink-commits

Reply via email to