Fix applying of postponed pts updates.

This commit is contained in:
levlam 2021-01-08 14:37:50 +03:00
parent 6b909386fd
commit eab5532688

View File

@ -8741,22 +8741,18 @@ void MessagesManager::after_get_difference() {
CHECK(!td_->updates_manager_->running_get_difference()); CHECK(!td_->updates_manager_->running_get_difference());
if (postponed_pts_updates_.size()) { if (postponed_pts_updates_.size()) {
LOG(INFO) << "Begin to apply postponed pts updates"; auto postponed_updates = std::move(postponed_pts_updates_);
auto old_pts = td_->updates_manager_->get_pts(); postponed_pts_updates_.clear();
for (auto &update : postponed_pts_updates_) {
auto new_pts = update.second.pts; LOG(INFO) << "Begin to apply " << postponed_updates.size() << " postponed pts updates";
if (new_pts <= old_pts) { for (auto &postponed_update : postponed_updates) {
skip_old_pending_update(std::move(update.second.update), new_pts, old_pts, update.second.pts_count, auto &update = postponed_update.second;
add_pending_update(std::move(update.update), update.pts, update.pts_count, false, std::move(update.promise),
"after get difference"); "after get difference");
update.second.promise.set_value(Unit());
} else {
add_pending_update(std::move(update.second.update), update.second.pts, update.second.pts_count, false,
std::move(update.second.promise), "after get difference");
}
CHECK(!td_->updates_manager_->running_get_difference()); CHECK(!td_->updates_manager_->running_get_difference());
} }
postponed_pts_updates_.clear(); LOG(INFO) << "Finish to apply postponed pts updates, have " << postponed_pts_updates_.size()
LOG(INFO) << "Finish to apply postponed pts updates"; << " left postponed updates";
} }
running_get_difference_ = false; running_get_difference_ = false;