Commit b16a1655 authored by hinoka@google.com's avatar hinoka@google.com

Be more aggressive about breaking locks

There is an issue where:
1. Lock for asdf.git acquires, which creates asdf.lock
2. asdf.git is cloned into tmp_asdf.git
3. Buildbot crashes, because timeouts
4. neither asdf.lock or tmp_asdf.git/config.lock gets cleaned out on the next unlock.

This aims to fix this issue by aggressively unlocking everything it can find that
vaguely resembles a lock.

BUG=339171

Review URL: https://codereview.chromium.org/187283005

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@255138 0039d316-1c4b-4281-b951-d872f2087c98
parent d59e761b
......@@ -243,6 +243,14 @@ def CMDunlock(parser, args):
repo_dirs = [os.path.join(options.cache_dir, path)
for path in os.listdir(options.cache_dir)
if os.path.isdir(os.path.join(options.cache_dir, path))]
repo_dirs.extend([os.path.join(options.cache_dir,
lockfile.replace('.lock', ''))
for lockfile in os.listdir(options.cache_dir)
if os.path.isfile(os.path.join(options.cache_dir,
lockfile))
and lockfile.endswith('.lock')
and os.path.join(options.cache_dir, lockfile)
not in repo_dirs])
lockfiles = [repo_dir + '.lock' for repo_dir in repo_dirs
if os.path.exists(repo_dir + '.lock')]
......@@ -255,11 +263,16 @@ def CMDunlock(parser, args):
untouched = []
for repo_dir in repo_dirs:
lf = Lockfile(repo_dir)
config_lock = os.path.join(repo_dir, 'config.lock')
unlocked = False
if os.path.exists(config_lock):
os.remove(config_lock)
unlocked = True
if lf.break_lock():
config_lock = os.path.join(repo_dir, 'config.lock')
if os.path.exists(config_lock):
os.remove(config_lock)
unlocked.append(repo_dir)
unlocked = True
if unlocked:
unlocked.append(repo_dir)
else:
untouched.append(repo_dir)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment