git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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;'
Previous: Nate ParsonsNext: Junio C Hamano
Message 4 of 10 in “git .lock file error”
  1. Nate ParsonsSep 13, 2010
  2. Nate ParsonsSep 20, 2010
  3. Nate ParsonsSep 30, 2010
  4. Ævar Arnfjörð BjarmasonSep 30, 2010
  5. Junio C HamanoSep 30, 2010
  6. Nate ParsonsSep 30, 2010
  7. Ævar Arnfjörð BjarmasonSep 30, 2010
  8. Erik Faye-LundSep 30, 2010
  9. Nate ParsonsOct 1, 2010
  10. Erik Faye-LundOct 1, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.