[PATCH stable] lock: handle race in trylock/testlock on Windows

Yuya Nishihara yuya at tcha.org
Wed Oct 2 09:33:53 CDT 2013


On Wed, 02 Oct 2013 18:11:09 +0400, Nikolaj Sjujskij wrote:
> On Wed, 02 Oct 2013 16:59:28 +0400, Yuya Nishihara <yuya at tcha.org> wrote:
> 
> > # HG changeset patch
> > # User Yuya Nishihara <yuya at tcha.org>
> > # Date 1380716200 -32400
> > #      Wed Oct 02 21:16:40 2013 +0900
> > # Branch stable
> > # Node ID 964b123c4831abac69efc5a089c446222915713f
> > # Parent  4d513f96a565639c0879086b68cf72a1e01e596c
> > lock: handle race in trylock/testlock on Windows
> >
> > readlock may raise IOError if the system does not support symlink.
> >
> > diff --git a/mercurial/lock.py b/mercurial/lock.py
> > --- a/mercurial/lock.py
> > +++ b/mercurial/lock.py
> > @@ -100,7 +100,7 @@ class lock(object):
> >          """
> >          try:
> >              locker = util.readlock(self.f)
> > -        except OSError, why:
> > +        except (OSError, IOError), why:
> >              if why.errno == errno.ENOENT:
> >                  return None
> >              raise
> 
>   Could IOError.errno == errno.ENOENT? Otherwise this change doesn't seem  
> to really change anything.

Yes.  I've confirmed the problem on Windows by inserting sleep(1) in trylock.
And if errno isn't ENOENT, the exception must be raised.

Regards,


More information about the Mercurial-devel mailing list