]> git.proxmox.com Git - pve-common.git/commitdiff
fix bug #273: retry flock if it fails with EINTR
authorDietmar Maurer <dietmar@proxmox.com>
Wed, 31 Oct 2012 07:22:40 +0000 (08:22 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 31 Oct 2012 07:22:40 +0000 (08:22 +0100)
Makefile
data/PVE/Tools.pm
debian/changelog

index 94fcaf79761289260d3b3f18355f7f80f237b699..454ab95041fa954a0c23a936134fb93089349404 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 RELEASE=2.2
 
 VERSION=1.0
-PKGREL=37
+PKGREL=38
 
 PACKAGE=libpve-common-perl
 
index 27b4361f7f11c9a6d76d3a48b0a9a465bc86c074..3212595fdd8306021d0fa30ceb6b87d72ff93413 100644 (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";
             }
index 3d3261177d1241db872d6108a556d92144ad0123..5fe1250b174dfbd7d0a15a4b67ce8393183f1a59 100644 (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