Don't send parallel ping-server requests.

This commit is contained in:
levlam 2023-01-03 15:32:10 +03:00
parent 62040c8d8e
commit 9834594b16
2 changed files with 7 additions and 0 deletions

View File

@ -1473,6 +1473,10 @@ void UpdatesManager::init_state() {
}
void UpdatesManager::ping_server() {
if (is_ping_sent_) {
return;
}
is_ping_sent_ = true;
auto promise = PromiseCreator::lambda([](Result<tl_object_ptr<telegram_api::updates_state>> result) {
auto state = result.is_ok() ? result.move_as_ok() : nullptr;
send_closure(G()->updates_manager(), &UpdatesManager::on_server_pong, std::move(state));
@ -1482,6 +1486,7 @@ void UpdatesManager::ping_server() {
void UpdatesManager::on_server_pong(tl_object_ptr<telegram_api::updates_state> &&state) {
LOG(INFO) << "Receive " << oneline(to_string(state));
is_ping_sent_ = false;
if (state == nullptr || state->pts_ > get_pts() || state->seq_ > seq_) {
get_difference("on server pong");
}

View File

@ -246,6 +246,8 @@ class UpdatesManager final : public Actor {
int32 min_postponed_update_qts_ = 0;
double get_difference_start_time_ = 0; // time from which we started to get difference without success
bool is_ping_sent_ = false;
FlatHashMap<int64, TranscribedAudioHandler> pending_audio_transcriptions_;
MultiTimeout pending_audio_transcription_timeout_{"PendingAudioTranscriptionTimeout"};