aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaner Altinbasak <cal@brightsign.biz>2021-10-13 13:14:41 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-10-14 22:32:52 +0100
commitfa39e6689d0f0fff772e1c81682698f4b1587b8a (patch)
tree3bed99c82fe9fd6a3982fcc3538a56f19e5d7bf3
parent22c18494c9072788e6e26eb73de70378ae5c5bf5 (diff)
downloadbitbake-fa39e6689d0f0fff772e1c81682698f4b1587b8a.tar.gz
npmsw: Avoid race condition with multiple npm fetchers
If multiple npmsw fetchers are trying to download the same npm file, one of them can try to download the file while other is calling verify. npmsw methods gets called without holding the lock, which causes race conditions in fetching and verification etc. Lock the lockfile before calling proxy fetcher methods. Signed-off-by: Caner Altinbasak <cal@brightsign.biz> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--lib/bb/fetch2/npmsw.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/bb/fetch2/npmsw.py b/lib/bb/fetch2/npmsw.py
index 9523cece1..426a13965 100644
--- a/lib/bb/fetch2/npmsw.py
+++ b/lib/bb/fetch2/npmsw.py
@@ -30,6 +30,8 @@ from bb.fetch2.npm import npm_integrity
from bb.fetch2.npm import npm_localfile
from bb.fetch2.npm import npm_unpack
from bb.utils import is_semver
+from bb.utils import lockfile
+from bb.utils import unlockfile
def foreach_dependencies(shrinkwrap, callback=None, dev=False):
"""
@@ -195,7 +197,9 @@ class NpmShrinkWrap(FetchMethod):
proxy_ud = ud.proxy.ud[proxy_url]
proxy_d = ud.proxy.d
proxy_ud.setup_localpath(proxy_d)
+ lf = lockfile(proxy_ud.lockfile)
returns.append(handle(proxy_ud.method, proxy_ud, proxy_d))
+ unlockfile(lf)
return returns
def verify_donestamp(self, ud, d):