libstore: simplify TransferSource::awaitData
don't pass in a lock that's only used inside this function.
Change-Id: I15c01e9cfe343cf13828ae3b3742c36ae697291f
This commit is contained in:
parent
5d02800e57
commit
90536e27e1
|
@ -893,11 +893,13 @@ struct curlFileTransfer : public FileTransfer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void awaitData(Sync<State>::Lock & state)
|
void awaitData()
|
||||||
{
|
{
|
||||||
/* Grab data if available, otherwise wait for the download
|
/* Grab data if available, otherwise wait for the download
|
||||||
thread to wake us up. */
|
thread to wake us up. */
|
||||||
while (buffered.empty()) {
|
while (buffered.empty()) {
|
||||||
|
auto state(_state->lock());
|
||||||
|
|
||||||
if (state->data.empty()) {
|
if (state->data.empty()) {
|
||||||
if (state->done) {
|
if (state->done) {
|
||||||
if (state->exc) {
|
if (state->exc) {
|
||||||
|
@ -929,10 +931,7 @@ struct curlFileTransfer : public FileTransfer
|
||||||
size_t total = readPartial(data, len);
|
size_t total = readPartial(data, len);
|
||||||
|
|
||||||
while (total < len) {
|
while (total < len) {
|
||||||
{
|
awaitData();
|
||||||
auto state(_state->lock());
|
|
||||||
awaitData(state);
|
|
||||||
}
|
|
||||||
const auto current = readPartial(data + total, len - total);
|
const auto current = readPartial(data + total, len - total);
|
||||||
total += current;
|
total += current;
|
||||||
if (total == 0 || current == 0) {
|
if (total == 0 || current == 0) {
|
||||||
|
@ -950,8 +949,7 @@ struct curlFileTransfer : public FileTransfer
|
||||||
|
|
||||||
auto metadata = item->metadataPromise.get_future().get();
|
auto metadata = item->metadataPromise.get_future().get();
|
||||||
auto source = make_box_ptr<TransferSource>(_state, item);
|
auto source = make_box_ptr<TransferSource>(_state, item);
|
||||||
auto lock(_state->lock());
|
source->awaitData();
|
||||||
source->awaitData(lock);
|
|
||||||
return {std::move(metadata), std::move(source)};
|
return {std::move(metadata), std::move(source)};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue