diff options
author | torne@chromium.org <torne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-08 13:52:50 +0000 |
---|---|---|
committer | torne@chromium.org <torne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-08 13:52:50 +0000 |
commit | 126b7060ab84793646b33307a842895fcdcf9cf9 (patch) | |
tree | 1ff50f7ed31fada35701e70c659b1e23e570fa23 /base | |
parent | 046cd7c278a705ae7e9e06d8209e0fa4010b2aba (diff) | |
download | chromium_src-126b7060ab84793646b33307a842895fcdcf9cf9.zip chromium_src-126b7060ab84793646b33307a842895fcdcf9cf9.tar.gz chromium_src-126b7060ab84793646b33307a842895fcdcf9cf9.tar.bz2 |
Android: fix race condition in jni_generator.
Instead of checking if the directory exists and then creating it, just
try and create it and catch the exception if it already exists. This
fixes a race that seems to occur when using the Android build system for
WebView, as it appears to run several instances of jni_generator at
exactly the same time.
BUG=
Review URL: https://codereview.chromium.org/12461009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@186952 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rwxr-xr-x | base/android/jni_generator/jni_generator.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/base/android/jni_generator/jni_generator.py b/base/android/jni_generator/jni_generator.py index 2c6394a..1ae5090 100755 --- a/base/android/jni_generator/jni_generator.py +++ b/base/android/jni_generator/jni_generator.py @@ -7,6 +7,7 @@ If you change this, please run and update the tests.""" import collections +import errno import optparse import os import re @@ -949,8 +950,11 @@ def ExtractJarInputFile(jar_file, input_file, out_dir): jar_file = zipfile.ZipFile(jar_file) out_dir = os.path.join(out_dir, os.path.dirname(input_file)) - if not os.path.exists(out_dir): + try: os.makedirs(out_dir) + except OSError as e: + if e.errno != errno.EEXIST: + raise extracted_file_name = os.path.join(out_dir, os.path.basename(input_file)) with open(extracted_file_name, 'w') as outfile: outfile.write(jar_file.read(input_file)) |