diff options
author | Caner Altinbasak <cal@brightsign.biz> | 2021-10-13 13:14:41 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-10-14 22:37:43 +0100 |
commit | 8e6aaed8ffc9ff823056ad38ccc57c56f0afea26 (patch) | |
tree | e0ed3a88b343b493d37f87367fa6828de1bf1cae | |
parent | 4c33a6e52be775265c871aa2d3b87ed23a0d48da (diff) | |
download | poky-8e6aaed8ffc9ff823056ad38ccc57c56f0afea26.tar.gz |
bitbake: 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.
(Bitbake rev: fa39e6689d0f0fff772e1c81682698f4b1587b8a)
Signed-off-by: Caner Altinbasak <cal@brightsign.biz>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | bitbake/lib/bb/fetch2/npmsw.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/bitbake/lib/bb/fetch2/npmsw.py b/bitbake/lib/bb/fetch2/npmsw.py index 9523cece1a..426a139653 100644 --- a/bitbake/lib/bb/fetch2/npmsw.py +++ b/bitbake/lib/bb/fetch2/npmsw.py | |||
@@ -30,6 +30,8 @@ from bb.fetch2.npm import npm_integrity | |||
30 | from bb.fetch2.npm import npm_localfile | 30 | from bb.fetch2.npm import npm_localfile |
31 | from bb.fetch2.npm import npm_unpack | 31 | from bb.fetch2.npm import npm_unpack |
32 | from bb.utils import is_semver | 32 | from bb.utils import is_semver |
33 | from bb.utils import lockfile | ||
34 | from bb.utils import unlockfile | ||
33 | 35 | ||
34 | def foreach_dependencies(shrinkwrap, callback=None, dev=False): | 36 | def foreach_dependencies(shrinkwrap, callback=None, dev=False): |
35 | """ | 37 | """ |
@@ -195,7 +197,9 @@ class NpmShrinkWrap(FetchMethod): | |||
195 | proxy_ud = ud.proxy.ud[proxy_url] | 197 | proxy_ud = ud.proxy.ud[proxy_url] |
196 | proxy_d = ud.proxy.d | 198 | proxy_d = ud.proxy.d |
197 | proxy_ud.setup_localpath(proxy_d) | 199 | proxy_ud.setup_localpath(proxy_d) |
200 | lf = lockfile(proxy_ud.lockfile) | ||
198 | returns.append(handle(proxy_ud.method, proxy_ud, proxy_d)) | 201 | returns.append(handle(proxy_ud.method, proxy_ud, proxy_d)) |
202 | unlockfile(lf) | ||
199 | return returns | 203 | return returns |
200 | 204 | ||
201 | def verify_donestamp(self, ud, d): | 205 | def verify_donestamp(self, ud, d): |