diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2018-07-31 17:26:04 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2018-07-31 17:26:04 +0200 |
commit | 4b4adbc93dafcd020d9d79b2d9e376a80c6f5fef (patch) | |
tree | 7694676b3613af1143ee9b37e8610ac1bce6aeb4 | |
parent | d9e8ab0ff25979baa5b3c852f6a5aeb7b9d2ed36 (diff) |
Fix race downloading into a sink
This fixes 'error 10 while decompressing xz file'.
https://hydra.nixos.org/build/78308551
-rw-r--r-- | src/libstore/download.cc | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/libstore/download.cc b/src/libstore/download.cc index 07acd5d0e..ecec0f205 100644 --- a/src/libstore/download.cc +++ b/src/libstore/download.cc @@ -718,15 +718,17 @@ void Downloader::download(DownloadRequest && request, Sink & sink) while (true) { checkInterrupt(); - if (state->quit) { - if (state->exc) std::rethrow_exception(state->exc); - break; - } - /* If no data is available, then wait for the download thread to wake us up. */ - if (state->data.empty()) + if (state->data.empty()) { + + if (state->quit) { + if (state->exc) std::rethrow_exception(state->exc); + break; + } + state.wait(state->avail); + } /* If data is available, then flush it to the sink and wake up the download thread if it's blocked on a full buffer. */ |