Limit the number of ignored updates before end of the first get difference.

This commit is contained in:
levlam 2023-10-14 03:00:54 +03:00
parent f098853eb5
commit 8a711b56d9
2 changed files with 10 additions and 6 deletions

View File

@ -257,8 +257,8 @@ UpdatesManager::UpdatesManager(Td *td, ActorShared<> parent) : td_(td), parent_(
pending_audio_transcription_timeout_.set_callback(on_pending_audio_transcription_timeout_callback);
pending_audio_transcription_timeout_.set_callback_data(static_cast<void *>(td_));
if (td_->option_manager_->get_option_integer("since_last_open") < 3600 && !td_->auth_manager_->is_bot()) {
finished_first_get_difference_ = true;
if (!td_->auth_manager_->is_authorized() || !td_->auth_manager_->is_bot()) {
skipped_postponed_updates_after_start_ = 0;
}
}
@ -2106,7 +2106,7 @@ void UpdatesManager::after_get_difference() {
retry_timeout_.cancel_timeout();
retry_time_ = 1;
finished_first_get_difference_ = true;
skipped_postponed_updates_after_start_ = 0;
td_->option_manager_->set_option_empty("since_last_open");
// cancels qts_gap_timeout_ if needed, can apply some updates received during getDifference,

View File

@ -263,7 +263,7 @@ class UpdatesManager final : public Actor {
bool are_sessions_inited_ = false;
bool running_get_difference_ = false;
bool finished_first_get_difference_ = false;
int32 skipped_postponed_updates_after_start_ = 50000;
int32 last_confirmed_pts_ = 0;
int32 last_confirmed_qts_ = 0;
int32 min_postponed_update_pts_ = 0;
@ -310,8 +310,12 @@ class UpdatesManager final : public Actor {
void on_qts_ack(PtsManager::PtsId ack_token);
void save_qts(int32 qts);
bool can_postpone_updates() const {
return finished_first_get_difference_;
bool can_postpone_updates() {
if (skipped_postponed_updates_after_start_ == 0) {
return true;
}
skipped_postponed_updates_after_start_--;
return false;
}
void set_date(int32 date, bool from_update, string date_source);