Patchwork D7199: lock: fix race in lock-breaking code

login
register
mail settings
Submitter phabricator
Date Nov. 19, 2019, 4:05 a.m.
Message ID <186a9369e7cb92250c96e0618d871de7@localhost.localdomain>
Download mbox | patch
Permalink /patch/43352/
State Not Applicable
Headers show

Comments

phabricator - Nov. 19, 2019, 4:05 a.m.
Closed by commit rHG355a6ef12ba9: lock: fix race in lock-breaking code (authored by valentin.gatienbaron).
This revision was automatically updated to reflect the committed changes.

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D7199?vs=17496&id=18232#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7199?vs=17496&id=18232

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7199/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7199

AFFECTED FILES
  mercurial/lock.py

CHANGE DETAILS




To: valentin.gatienbaron, #hg-reviewers, indygreg
Cc: indygreg, mercurial-devel

Patch

diff --git a/mercurial/lock.py b/mercurial/lock.py
--- a/mercurial/lock.py
+++ b/mercurial/lock.py
@@ -355,6 +355,11 @@ 
         # held, or can race and break valid lock.
         try:
             with lock(self.vfs, self.f + b'.break', timeout=0):
+                 locker = self._readlock()
+                 if not self._lockshouldbebroken(locker):
+                     return locker
+                 self.vfs.unlink(self.f)
+
                 self.vfs.unlink(self.f)
         except error.LockError:
             return locker