# HG changeset patch # User Bryan O'Sullivan # Date 1365712227 25200 # Node ID af9fa8d4c9399146c3a241ea02677ca53192e628 # Parent ef7068173a22ba660af2d124a59316002509d95a lock: if we fork, ensure that only the parent releases This prevents us from having a bunch of errant worker processes all try to release a lock if a problem occurs. (Releasing the lock more than once is harmless; it's invoking the associated callbacks we want to avoid.) diff -r ef7068173a22 -r af9fa8d4c939 mercurial/lock.py --- a/mercurial/lock.py Thu Apr 11 14:44:22 2013 +0200 +++ b/mercurial/lock.py Thu Apr 11 13:30:27 2013 -0700 @@ -36,6 +36,7 @@ self.releasefn = releasefn self.desc = desc self.postrelease = [] + self.pid = os.getpid() self.lock() def __del__(self): @@ -71,7 +72,7 @@ return if lock._host is None: lock._host = socket.gethostname() - lockname = '%s:%s' % (lock._host, os.getpid()) + lockname = '%s:%s' % (lock._host, self.pid) while not self.held: try: util.makelock(lockname, self.f) @@ -133,6 +134,9 @@ self.held -= 1 elif self.held == 1: self.held = 0 + if os.getpid() != self.pid: + # we forked, and are not the parent + return if self.releasefn: self.releasefn() try: