fix bug #273: retry flock if it fails with EINTR

This commit is contained in:
Dietmar Maurer 2012-10-31 08:22:40 +01:00
parent e0cabd2caa
commit b5d12b0845
3 changed files with 17 additions and 3 deletions

View File

@ -1,7 +1,7 @@
RELEASE=2.2
VERSION=1.0
PKGREL=37
PKGREL=38
PACKAGE=libpve-common-perl

View File

@ -1,7 +1,7 @@
package PVE::Tools;
use strict;
use POSIX;
use POSIX qw(EINTR);
use IO::Socket::INET;
use IO::Select;
use File::Basename;
@ -92,7 +92,15 @@ sub lock_file {
if (!flock ($lock_handles->{$$}->{$filename}, LOCK_EX|LOCK_NB)) {
print STDERR "trying to aquire lock...";
if (!flock ($lock_handles->{$$}->{$filename}, LOCK_EX)) {
my $success;
while(1) {
$success = flock($lock_handles->{$$}->{$filename}, LOCK_EX);
# try again on EINTR (see bug #273)
if ($success || ($! != EINTR)) {
last;
}
}
if (!$success) {
print STDERR " failed\n";
die "can't aquire lock - $!\n";
}

6
debian/changelog vendored
View File

@ -1,3 +1,9 @@
libpve-common-perl (1.0-38) unstable; urgency=low
* fix bug #273: retry flock if it fails with EINTR
-- Proxmox Support Team <support@proxmox.com> Wed, 31 Oct 2012 08:21:43 +0100
libpve-common-perl (1.0-37) unstable; urgency=low
* fix bug #264: use option pipefail for shell commands