Re: git .lock file error
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Sep 30, 2010, 19:13 UTC
- Message-ID
- <AANLkTik364t7WEHOsZcB7FE4Y2gJQNxkXsRvW5guUWCi@mail.gmail.com>
- In-Reply-To
- <AANLkTim2sFCx8qZ-6o4tiugX3a-EBN9T8wuCSWXb5L12@mail.gmail.com>
On Thu, Sep 30, 2010 at 18:00, Nate Parsons <parsons.nate@gmail.com> wrote:
> OK, so this is definitely a win32 issue. I believe that the perl > script is simply creating .lock files too fast for Windows to keep up. > Simply trying again fixes the problem for me.
Sounds like something that might do with a non-hacky solution, but I don't know what that would be.
Show 9 quoted lines
> - sysopen(my $fh, $db_lock, O_RDWR | O_CREAT)
> - or croak "Couldn't open $db_lock: $!\n";
> + my $fh;
> + my $tries=10;
> + for(; !sysopen($fh, $db_lock, O_RDWR | O_CREAT) && $tries>=0; $tries--) { }
> + if($tries <= 0) { croak "Couldn't open $db_lock: $!\n"; }
> $update_ref eq 'reset' ? _rev_map_reset($fh, $rev, $commit) :
> _rev_map_set($fh, $rev, $commit);
> if ($sync) {FWIW I think this is more readable, but maybe we want to retry on all platforms:
my $fh;
if ($^O eq 'MSWin32' or $^O eq 'cygwin') {
# Try 10 times to open our lock file, in case Windows is lagging
for my $try (1..10) {
sysopen($fh, $db_lock, O_RDWR | O_CREAT);
last if $fh;
}
} else {
sysopen($fh, $db_lock, O_RDWR | O_CREAT);
}warn "Couldnt open $db_lock: $!\n" unless $fh;'