Check connection aliveness after push is received.

GitOrigin-RevId: 526a06642617ada66ef6d84f5858cb332f1c1406
This commit is contained in:
levlam 2019-03-31 22:29:34 +03:00
parent 2f8aa42776
commit 295878b217
4 changed files with 14 additions and 2 deletions

View File

@ -713,10 +713,11 @@ Status SessionConnection::init() {
}
void SessionConnection::set_online(bool online_flag, bool is_main) {
bool need_ping = online_flag || !online_flag_;
online_flag_ = online_flag;
is_main_ = is_main;
auto now = Time::now();
if (online_flag_) {
if (need_ping) {
last_pong_at_ = now - ping_disconnect_delay() + rtt();
last_read_at_ = now - read_disconnect_delay() + rtt();
} else {

View File

@ -2520,6 +2520,12 @@ void NotificationManager::process_push_notification(string payload, Promise<Unit
break;
}
}
if (!td_->is_online()) {
// reset online flag to false to immediately check all connections aliveness
send_closure(G()->state_manager(), &StateManager::on_online, false);
}
if (receiver_id == 0 || receiver_id == G()->get_my_id()) {
auto status = process_push_notification_payload(payload);
if (status.is_error()) {

View File

@ -564,6 +564,10 @@ void SecretChatsManager::flush_pending_chat_updates() {
}
void SecretChatsManager::on_online(bool is_online) {
if (is_online_ == is_online) {
return;
}
is_online_ = is_online;
flush_pending_chat_updates();
}

View File

@ -776,8 +776,9 @@ void ConnectionCreator::on_network(bool network_flag, uint32 network_generation)
void ConnectionCreator::on_online(bool online_flag) {
VLOG(connections) << "Receive online flag " << online_flag;
bool need_drop_flood_control = online_flag || !online_flag_;
online_flag_ = online_flag;
if (online_flag_) {
if (need_drop_flood_control) {
for (auto &client : clients_) {
client.second.backoff.clear();
client.second.flood_control_online.clear_events();