summaryrefslogtreecommitdiffstats
path: root/config-db
diff options
context:
space:
mode:
authorOliver Tappe2008-09-13 00:00:46 +0200
committerOliver Tappe2008-09-13 00:00:46 +0200
commiteca5f2e81a7c859bfbd378b5f5cd7c7b5d4ba0b0 (patch)
tree555152e7baf8f0cc79dfb1f679af99737c183b5a /config-db
parentadder version 3.71 of pxelinux-stuff (diff)
downloadcore-eca5f2e81a7c859bfbd378b5f5cd7c7b5d4ba0b0.tar.gz
core-eca5f2e81a7c859bfbd378b5f5cd7c7b5d4ba0b0.tar.xz
core-eca5f2e81a7c859bfbd378b5f5cd7c7b5d4ba0b0.zip
* implemented support for recursive file-based locks
* used improved locking mechanism to protect not only slxconfig-demuxer against being executed twice, but also to avoid two different process groups from chrooting into the same vendor-OS git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@2213 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'config-db')
-rwxr-xr-xconfig-db/slxconfig-demuxer44
1 files changed, 2 insertions, 42 deletions
diff --git a/config-db/slxconfig-demuxer b/config-db/slxconfig-demuxer
index 7234b762..942b8a88 100755
--- a/config-db/slxconfig-demuxer
+++ b/config-db/slxconfig-demuxer
@@ -31,7 +31,6 @@ slxconfig-demuxer
use Config::General;
use Digest::MD5 qw(md5_hex);
-use Fcntl qw(:DEFAULT :flock);
use File::Basename;
use File::Find;
use File::Path;
@@ -50,7 +49,6 @@ use OpenSLX::Basics;
use OpenSLX::ConfigDB qw(:support);
use OpenSLX::ConfigFolder;
use OpenSLX::OSPlugin::Roster;
-use OpenSLX::ScopedResource;
use OpenSLX::Utils;
my (
@@ -110,46 +108,8 @@ if (createConfigFolderForDefaultSystem()) {
);
}
-# protect against parallel executions of this script
-my $criticalSection = OpenSLX::ScopedResource->new({
- name => 'osplugin::session',
- acquire => sub {
- return if $option{dryRun};
-
- # use a lock-file to singularize execution of this script:
- my $lockFile = "$openslxConfig{'private-path'}/config-demuxer.lock";
- if (-e $lockFile) {
- my $ctime = (stat($lockFile))[10];
- my $now = time();
- if ($now - $ctime > 15 * 60) {
- # existing lock file is older than 15 minutes, wipe it:
- unlink $lockFile;
- }
- }
- if (!sysopen(LOCKFILE, $lockFile, O_RDWR | O_CREAT | O_EXCL)) {
- if ($! == 13) {
- die _tr(qq[Unable to create lock-file <%s>, exiting!\n], $lockFile);
- } else {
- die _tr(unshiftHereDoc(<<" End-of-Here"),
- Lock-file '%s' exists, script is already running.
- Please remove the logfile and try again if you are sure that no one else
- is executing this script.
- End-of-Here
- $lockFile
- );
- }
- }
- 1
- },
- release => sub {
- return if $option{dryRun};
-
- my $lockFile = "$openslxConfig{'private-path'}/config-demuxer.lock";
- close(LOCKFILE);
- unlink $lockFile;
- 1
- },
-});
+# protect against parallel executions of writing OpenSLX scripts
+my $globalLock = grabLock('global');
my $tempPath = "$openslxConfig{'temp-path'}/slxconfig-demuxer";
if (!$option{dryRun}) {