D7199: lock: fix race in lock-breaking code

valentin.gatienbaron (Valentin Gatien-Baron) phabricator at mercurial-scm.org
Mon Nov 18 23:05:50 EST 2019


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

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



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


More information about the Mercurial-devel mailing list