From e15b48be8634d566329b4a3e0b6cf49820145710 Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Tue, 15 Nov 2011 01:44:30 +0100 Subject: [PATCH] parallel: If flock is unimplemented: Wait for random*5 sec instead. --- src/parallel | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/parallel b/src/parallel index 94b2e1da..be03ef0b 100755 --- a/src/parallel +++ b/src/parallel @@ -4914,6 +4914,14 @@ sub lock { chmod 0666, $self->{'lockfile'}; # assuming you want it a+rw $Global::use{"Fcntl"} ||= eval "use Fcntl qw(:DEFAULT :flock);"; while(not flock $self->{'lockfh'}, LOCK_EX()|LOCK_NB()) { + if ($! =~ m/Function not implemented/) { + print $Global::original_stderr + ("parallel: Warning: flock: $!"); + print "parallel: Will wait for a random while\n"; + ::usleep(rand(5000)); + last; + } + ::debug("Cannot lock $self->{'lockfile'}"); # TODO if timeout: last $sleep = ($sleep < 1000) ? ($sleep * 1.1) : ($sleep);