Skip to content
This repository has been archived by the owner on Jul 5, 2023. It is now read-only.

Commit

Permalink
Fix race condition in gitdeps.py
Browse files Browse the repository at this point in the history
The loop to delete orphaned directories uses threading to delete directories
in parallel.  Threads were created from a lambda function, which closed a
variable. The variable was redefined in a loop, which lead to a race condition.

BUG=

Review-Url: https://codereview.chromium.org/2693863004
  • Loading branch information
apchhee authored and Commit bot committed Feb 14, 2017
1 parent a2c8d4e commit 56b2e02
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions syzygy/build/gitdeps.py
Expand Up @@ -529,8 +529,8 @@ def _InstallRepository(options, repo):
_RemoveOrphanedJunction(options, j)

newpath = _RenameCheckout(repo.checkout_dir, options.dry_run)
body = lambda: _DeleteCheckout(newpath, options.dry_run)
thread = threading.Thread(target=body)
thread = threading.Thread(target=_DeleteCheckout,
args=(newpath, options.dry_run))
threads.append(thread)
thread.start()

Expand Down Expand Up @@ -902,8 +902,8 @@ def main():
for path in glob.glob(os.path.join(options.cache_dir, '*')):
if os.path.join(path, 'src') not in checkout_dirs:
_LOGGER.debug('Erasing orphaned checkout directory: %s', path)
body = lambda: _DeleteCheckout(path, options.dry_run)
thread = threading.Thread(target=body)
thread = threading.Thread(target=_DeleteCheckout,
args=(path, options.dry_run))
threads.append(thread)
thread.start()
for thread in threads:
Expand Down

0 comments on commit 56b2e02

Please sign in to comment.