Compare commits
2 Commits
d2928e5580
...
4a203ebf47
Author | SHA1 | Date | |
---|---|---|---|
4a203ebf47 | |||
f260f1d50a |
@ -108,13 +108,14 @@ void open_file::download_chunk(std::size_t chunk, bool skip_active,
|
|||||||
if ((get_api_error() == api_error::success) && (chunk < read_state_.size()) &&
|
if ((get_api_error() == api_error::success) && (chunk < read_state_.size()) &&
|
||||||
not read_state_[chunk]) {
|
not read_state_[chunk]) {
|
||||||
if (active_downloads_.find(chunk) != active_downloads_.end()) {
|
if (active_downloads_.find(chunk) != active_downloads_.end()) {
|
||||||
if (not skip_active) {
|
if (skip_active) {
|
||||||
auto active_download = active_downloads_.at(chunk);
|
return;
|
||||||
download_lock.unlock();
|
|
||||||
|
|
||||||
active_download->wait();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto active_download = active_downloads_.at(chunk);
|
||||||
|
download_lock.unlock();
|
||||||
|
|
||||||
|
active_download->wait();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -558,17 +559,18 @@ void open_file::update_background_reader(std::size_t read_chunk) {
|
|||||||
}
|
}
|
||||||
io_thread_notify_.notify_all();
|
io_thread_notify_.notify_all();
|
||||||
io_lock.unlock();
|
io_lock.unlock();
|
||||||
} else {
|
continue;
|
||||||
do {
|
|
||||||
next_chunk = read_chunk_ =
|
|
||||||
((read_chunk_ + 1U) >= read_state_.size()) ? 0U
|
|
||||||
: read_chunk_ + 1U;
|
|
||||||
} while ((next_chunk != 0U) && (active_downloads_.find(next_chunk) !=
|
|
||||||
active_downloads_.end()));
|
|
||||||
|
|
||||||
file_lock.unlock();
|
|
||||||
download_chunk(next_chunk, true, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do {
|
||||||
|
next_chunk = read_chunk_ = ((read_chunk_ + 1U) >= read_state_.size())
|
||||||
|
? 0U
|
||||||
|
: read_chunk_ + 1U;
|
||||||
|
} while ((next_chunk != 0U) && (active_downloads_.find(next_chunk) !=
|
||||||
|
active_downloads_.end()));
|
||||||
|
|
||||||
|
file_lock.unlock();
|
||||||
|
download_chunk(next_chunk, true, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user