FileLoader: fix queries cancelling

GitOrigin-RevId: 8350a262e0c51563e987e66e77ba1922bb2f5a4d
This commit is contained in:
Arseny Smirnov 2020-08-21 16:32:31 +03:00
parent e3fa28d457
commit 51ff6105cb
2 changed files with 7 additions and 6 deletions

View File

@ -67,11 +67,12 @@ void FileLoader::update_local_file_location(const LocalFileLocation &local) {
void FileLoader::update_download_offset(int64 offset) { void FileLoader::update_download_offset(int64 offset) {
if (parts_manager_.get_streaming_offset() != offset) { if (parts_manager_.get_streaming_offset() != offset) {
uint64 begin_part_id = parts_manager_.set_streaming_offset(offset); auto begin_part_id = parts_manager_.set_streaming_offset(offset);
uint64 end_part_id = begin_part_id + part_map_.size(); auto end_part_id = begin_part_id + static_cast<int32>(part_map_.size()) * 2;
//TODO: cancel only some queries VLOG(files) << "Protect parts " << begin_part_id << " ... " << end_part_id;
for (auto &it : part_map_) { for (auto &it : part_map_) {
if (!(begin_part_id <= it.first && it.first < end_part_id)) { if (!(begin_part_id <= it.second.first.id && it.second.first.id < end_part_id)) {
VLOG(files) << "Cancel part " << it.second.first.id;
it.second.second.reset(); // cancel_query(it.second.second); it.second.second.reset(); // cancel_query(it.second.second);
} }
} }

View File

@ -32,8 +32,8 @@ Status PartsManager::init_known_prefix(int64 known_prefix, size_t part_size, con
int32 PartsManager::set_streaming_offset(int64 offset) { int32 PartsManager::set_streaming_offset(int64 offset) {
auto finish = [&] { auto finish = [&] {
set_streaming_limit(streaming_limit_); set_streaming_limit(streaming_limit_);
update_first_empty_part(); update_first_not_ready_part();
return first_streaming_empty_part_; return first_streaming_not_ready_part_;
}; };
if (offset < 0 || need_check_ || (!unknown_size_flag_ && get_size() < offset)) { if (offset < 0 || need_check_ || (!unknown_size_flag_ && get_size() < offset)) {