From: Dietmar Maurer Date: Wed, 31 Oct 2012 07:22:40 +0000 (+0100) Subject: fix bug #273: retry flock if it fails with EINTR X-Git-Url: https://git.proxmox.com/?p=pve-common.git;a=commitdiff_plain;h=b5d12b08455e316e42843171abf8c054d33dd5bf fix bug #273: retry flock if it fails with EINTR --- diff --git a/Makefile b/Makefile index 94fcaf7..454ab95 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ RELEASE=2.2 VERSION=1.0 -PKGREL=37 +PKGREL=38 PACKAGE=libpve-common-perl diff --git a/data/PVE/Tools.pm b/data/PVE/Tools.pm index 27b4361..3212595 100644 --- a/data/PVE/Tools.pm +++ b/data/PVE/Tools.pm @@ -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"; } diff --git a/debian/changelog b/debian/changelog index 3d32611..5fe1250 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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 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