diff options
author | Jimb Esser <jimb@yahoo-inc.com> | 2016-01-14 00:43:02 +0300 |
---|---|---|
committer | Rebecca Turner <me@re-becca.org> | 2016-01-21 04:08:40 +0300 |
commit | 69ac9333506752bf2e5af70b3b3e03c6181de3e7 (patch) | |
tree | 525ab1e898b452ff08ac44af6041b1a9594531f9 /doc | |
parent | e6d238a3d90beeb0af23fa75a9b5e50671d6e4c5 (diff) |
install: fix race condition correcting cache directory ownership
Previously, correctMkdir() would cache the results early within its
operation (after the stat, before calling chownr) meaning that any second
call would immediately return the cached results, before the earlier chownr
finishes. This causes a race condition where the initial chownr would fail
with ENOENT (or similar errors) trying to scan files that were being
actively created/deleted/etc by the install process. The fix guards the
whole correctMkdir function with inflight() so that multiple calls do not do
chownr simultaneously nor return early. It would also be reasonable to not
cache the results until after the chownr has finished, however that would
still lead to an even more subtle race condition, so the guard on the whole
call is required.
PR-URL: https://github.com/npm/npm/pull/11142
Credit: @Jimbly
Reviewed-By: @othiym23
Diffstat (limited to 'doc')
0 files changed, 0 insertions, 0 deletions