Simplify check that all updates were processed.
This commit is contained in:
parent
7129a6d090
commit
a7e2e85119
@ -1663,7 +1663,6 @@ void UpdatesManager::on_pending_updates(vector<tl_object_ptr<telegram_api::Updat
|
|||||||
return promise.set_value(Unit());
|
return promise.set_value(Unit());
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t processed_updates = 0;
|
|
||||||
MultiPromiseActorSafe mpas{"OnPendingUpdatesMultiPromiseActor"};
|
MultiPromiseActorSafe mpas{"OnPendingUpdatesMultiPromiseActor"};
|
||||||
mpas.add_promise(std::move(promise));
|
mpas.add_promise(std::move(promise));
|
||||||
auto lock = mpas.get_promise();
|
auto lock = mpas.get_promise();
|
||||||
@ -1688,17 +1687,14 @@ void UpdatesManager::on_pending_updates(vector<tl_object_ptr<telegram_api::Updat
|
|||||||
LOG(ERROR) << "Update: " << oneline(to_string(debug_update));
|
LOG(ERROR) << "Update: " << oneline(to_string(debug_update));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
processed_updates++;
|
|
||||||
update = nullptr;
|
update = nullptr;
|
||||||
}
|
}
|
||||||
if (id == telegram_api::updateFolderPeers::ID) {
|
if (id == telegram_api::updateFolderPeers::ID) {
|
||||||
on_update(move_tl_object_as<telegram_api::updateFolderPeers>(update), mpas.get_promise());
|
on_update(move_tl_object_as<telegram_api::updateFolderPeers>(update), mpas.get_promise());
|
||||||
processed_updates++;
|
|
||||||
update = nullptr;
|
update = nullptr;
|
||||||
}
|
}
|
||||||
if (id == telegram_api::updateEncryption::ID) {
|
if (id == telegram_api::updateEncryption::ID) {
|
||||||
on_update(move_tl_object_as<telegram_api::updateEncryption>(update), mpas.get_promise());
|
on_update(move_tl_object_as<telegram_api::updateEncryption>(update), mpas.get_promise());
|
||||||
processed_updates++;
|
|
||||||
update = nullptr;
|
update = nullptr;
|
||||||
}
|
}
|
||||||
CHECK(!running_get_difference_);
|
CHECK(!running_get_difference_);
|
||||||
@ -1709,7 +1705,6 @@ void UpdatesManager::on_pending_updates(vector<tl_object_ptr<telegram_api::Updat
|
|||||||
if (update != nullptr) {
|
if (update != nullptr) {
|
||||||
if (is_pts_update(update.get()) || is_qts_update(update.get())) {
|
if (is_pts_update(update.get()) || is_qts_update(update.get())) {
|
||||||
downcast_call(*update, OnUpdate(this, update, mpas.get_promise()));
|
downcast_call(*update, OnUpdate(this, update, mpas.get_promise()));
|
||||||
processed_updates++;
|
|
||||||
update = nullptr;
|
update = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1723,9 +1718,18 @@ void UpdatesManager::on_pending_updates(vector<tl_object_ptr<telegram_api::Updat
|
|||||||
return lock.set_value(Unit());
|
return lock.set_value(Unit());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (processed_updates == updates.size() && seq_begin == 0 && seq_end == 0) {
|
if (seq_begin == 0 && seq_end == 0) {
|
||||||
LOG(INFO) << "All updates was processed";
|
bool have_updates = false;
|
||||||
return lock.set_value(Unit());
|
for (auto &update : updates) {
|
||||||
|
if (update != nullptr) {
|
||||||
|
have_updates = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!have_updates) {
|
||||||
|
LOG(INFO) << "All updates was processed";
|
||||||
|
return lock.set_value(Unit());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (seq_begin == 0 || seq_begin == seq_ + 1) {
|
if (seq_begin == 0 || seq_begin == seq_ + 1) {
|
||||||
|
Loading…
Reference in New Issue
Block a user