Don't send parallel ping-server requests.
This commit is contained in:
parent
62040c8d8e
commit
9834594b16
@ -1473,6 +1473,10 @@ void UpdatesManager::init_state() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void UpdatesManager::ping_server() {
|
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 promise = PromiseCreator::lambda([](Result<tl_object_ptr<telegram_api::updates_state>> result) {
|
||||||
auto state = result.is_ok() ? result.move_as_ok() : nullptr;
|
auto state = result.is_ok() ? result.move_as_ok() : nullptr;
|
||||||
send_closure(G()->updates_manager(), &UpdatesManager::on_server_pong, std::move(state));
|
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) {
|
void UpdatesManager::on_server_pong(tl_object_ptr<telegram_api::updates_state> &&state) {
|
||||||
LOG(INFO) << "Receive " << oneline(to_string(state));
|
LOG(INFO) << "Receive " << oneline(to_string(state));
|
||||||
|
is_ping_sent_ = false;
|
||||||
if (state == nullptr || state->pts_ > get_pts() || state->seq_ > seq_) {
|
if (state == nullptr || state->pts_ > get_pts() || state->seq_ > seq_) {
|
||||||
get_difference("on server pong");
|
get_difference("on server pong");
|
||||||
}
|
}
|
||||||
|
@ -246,6 +246,8 @@ class UpdatesManager final : public Actor {
|
|||||||
int32 min_postponed_update_qts_ = 0;
|
int32 min_postponed_update_qts_ = 0;
|
||||||
double get_difference_start_time_ = 0; // time from which we started to get difference without success
|
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_;
|
FlatHashMap<int64, TranscribedAudioHandler> pending_audio_transcriptions_;
|
||||||
MultiTimeout pending_audio_transcription_timeout_{"PendingAudioTranscriptionTimeout"};
|
MultiTimeout pending_audio_transcription_timeout_{"PendingAudioTranscriptionTimeout"};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user