X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=perl%2FAmanda%2FChanger%2Fdisk.pm;fp=perl%2FAmanda%2FChanger%2Fdisk.pm;h=3ff28b688d904e1d56906088c4b46cf9074be7a6;hb=691567b16c13087b31ee4c2b6d038e57872fae82;hp=8c18e65ce91d6a32e78c8153d274390c9c4c4397;hpb=cc7d7b45afc706099acf7ff2490ec5667d370651;p=debian%2Famanda diff --git a/perl/Amanda/Changer/disk.pm b/perl/Amanda/Changer/disk.pm index 8c18e65..3ff28b6 100644 --- a/perl/Amanda/Changer/disk.pm +++ b/perl/Amanda/Changer/disk.pm @@ -1,8 +1,9 @@ # Copyright (c) 2008-2012 Zmanda, Inc. All Rights Reserved. # -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 as published -# by the Free Software Foundation. +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY @@ -101,6 +102,11 @@ sub new { bless ($self, $class); + if ($config->{'changerfile'}) { + $self->{'state_filename'} = Amanda::Config::config_dir_relative($config->{'changerfile'}); + } + $self->{'lock-timeout'} = $config->get_property('lock-timeout'); + $self->{'num-slot'} = $config->get_property('num-slot'); $self->{'auto-create-slot'} = $config->get_boolean_property( 'auto-create-slot', 0); @@ -647,6 +653,14 @@ sub try_lock { my $self = shift; my $cb = shift; my $poll = 0; # first delay will be 0.1s; see below + my $time; + + if (defined $self->{'lock-timeout'}) { + $time = time() + $self->{'lock-timeout'}; + } else { + $time = time() + 1000; + } + my $steps = define_steps cb_ref => \$cb; @@ -661,10 +675,13 @@ sub try_lock { step lock => sub { my $rv = $self->{'fl'}->lock_rd(); - if ($rv == 1) { + if ($rv == 1 && time() < $time) { # loop until we get the lock, increasing $poll to 10s $poll += 100 unless $poll >= 10000; return Amanda::MainLoop::call_after($poll, $steps->{'lock'}); + } elsif ($rv == 1) { + return $self->make_error("fatal", $cb, + message => "Timeout trying to lock '$self->{'umount_lockfile'}'"); } elsif ($rv == -1) { return $self->make_error("fatal", $cb, message => "Error locking '$self->{'umount_lockfile'}'");