Fix race condition
If two processes were instantiated to the same repository and received capabilities roughly at the same time, causing one to wait for the other's pull to finish, the subsequent pull would be performed on a "dirty" instance of the repository, possibly causing repository corruption. This is fixed by taking a lock at the outer level, invalidating, then performing the pull with the lock already in place.
This commit is contained in:
Родитель
feb9d89130
Коммит
a3a73bc905
|
@ -115,10 +115,15 @@ peercache = dict()
|
|||
|
||||
def pull(repo, remote):
|
||||
"""41421bd9c42e dropped localrepo.pull"""
|
||||
lock = repo.lock()
|
||||
try:
|
||||
return repo.pull(remote)
|
||||
except AttributeError:
|
||||
return exchange.pull(repo, remote).cgresult
|
||||
repo.invalidate()
|
||||
try:
|
||||
return repo.pull(remote)
|
||||
except AttributeError:
|
||||
return exchange.pull(repo, remote).cgresult
|
||||
finally:
|
||||
lock.release()
|
||||
|
||||
class proxyserver(object):
|
||||
def __init__(self, ui=None, serverurl=None, cachepath=None, anonymous=None, unc=True,
|
||||
|
|
Загрузка…
Ссылка в новой задаче