fix(3p/nix/store): fix race condition in downloader
In certain circumstances, the decompression thread could race ahead of the downloader thread and process the same chunk twice. Clear the data buffer while the lock is held to prevent this kind of incident. Change-Id: I19a84a0c5768d1228c6c18a7664a7b8893ef96de Reviewed-on: https://cl.tvl.fyi/c/depot/+/1658 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi>
This commit is contained in:
parent
3f923b2aa0
commit
f10d60a454
1 changed files with 2 additions and 1 deletions
3
third_party/nix/src/libstore/download.cc
vendored
3
third_party/nix/src/libstore/download.cc
vendored
|
@ -835,7 +835,8 @@ void Downloader::download(DownloadRequest&& request, Sink& sink) {
|
|||
state.wait(state->avail);
|
||||
}
|
||||
|
||||
chunk = state->data;
|
||||
chunk = std::move(state->data);
|
||||
state->data = std::string();
|
||||
|
||||
state->request.notify_one();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue