mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 17:27:53 +03:00
avoid deadlocks when working with shared repos
Summary: Lock ordering is important. When working with shared repos, when we aquire a shared wlock, we must also acquire the master repo's wlock to ensure that any operations that might later grab the lock are properly ordered. Reviewed By: quark-zju, simpkins Differential Revision: D9613877 fbshipit-source-id: 2c3eeeea534cdf49f3bd7e94db441c3a1479a959
This commit is contained in:
parent
a85cac573c
commit
fee11729ac
@ -1831,7 +1831,16 @@ class localrepository(object):
|
||||
if self._currentlock(self._lockref) is not None:
|
||||
self.ui.develwarn('"wlock" acquired after "lock"')
|
||||
|
||||
# if this is a shared repo and we must also lock the shared wlock
|
||||
# or else we can deadlock due to lock ordering issues
|
||||
srcwlock = None
|
||||
srcrepo = self._getsrcrepo()
|
||||
if srcrepo:
|
||||
srcwlock = srcrepo.wlock()
|
||||
|
||||
def unlock():
|
||||
if srcwlock:
|
||||
srcwlock.release()
|
||||
if self.dirstate.pendingparentchange():
|
||||
self.dirstate.invalidate()
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user