Skip to content

Commit

Permalink
Minor fixes.
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 28f8cabca2f70ba692f8713ec68866495061b31a
  • Loading branch information
levlam committed Aug 5, 2020
1 parent c489d71 commit c5059bc
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
3 changes: 2 additions & 1 deletion td/telegram/AuthManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "td/telegram/net/NetQueryDispatcher.h"
#include "td/telegram/NotificationManager.h"
#include "td/telegram/PasswordManager.h"
#include "td/telegram/StateManager.h"
#include "td/telegram/StickersManager.h"
#include "td/telegram/Td.h"
#include "td/telegram/TdDb.h"
Expand Down Expand Up @@ -837,7 +838,7 @@ void AuthManager::update_state(State new_state, bool force, bool should_save_sta
if (should_save_state) {
save_state();
}
if (new_state == State::LoggingOut || new_state == State::DestroyingKeys || new_state == State::Closing) {
if (new_state == State::LoggingOut || new_state == State::DestroyingKeys) {
send_closure(G()->state_manager(), &StateManager::on_logging_out, true);
}
send_closure(G()->td(), &Td::send_update,
Expand Down
2 changes: 1 addition & 1 deletion td/telegram/StateManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void StateManager::on_logging_out(bool is_logging_out) {

void StateManager::add_callback(unique_ptr<Callback> callback) {
if (callback->on_network(network_type_, network_generation_) && callback->on_online(online_flag_) &&
callback->on_state(get_real_state())) {
callback->on_state(get_real_state()) && callback->on_logging_out(is_logging_out_)) {
callbacks_.push_back(std::move(callback));
}
}
Expand Down
2 changes: 1 addition & 1 deletion td/telegram/StateManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class StateManager final : public Actor {
uint32 network_generation_ = 1;
bool online_flag_ = false;
bool use_proxy_ = false;
bool is_logging_out_ = true;
bool is_logging_out_ = false;

static constexpr double UP_DELAY = 0.05;
static constexpr double DOWN_DELAY = 0.3;
Expand Down
14 changes: 9 additions & 5 deletions td/telegram/net/ConnectionCreator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,19 +569,23 @@ void ConnectionCreator::on_online(bool online_flag) {
online_flag_ = online_flag;
if (need_drop_flood_control) {
for (auto &client : clients_) {
client.second.sanity_flood_control.clear_events();
client.second.backoff.clear();
client.second.sanity_flood_control.clear_events();
client.second.flood_control_online.clear_events();
client_loop(client.second);
}
}
}
void ConnectionCreator::on_logging_out(bool is_logging_out) {
if (is_logging_out_ == is_logging_out) {
return;
}

VLOG(connections) << "Receive logging out flag " << is_logging_out;
is_logging_out_ = is_logging_out;
for (auto &client : clients_) {
client.second.sanity_flood_control.clear_events();
client.second.backoff.clear();
client.second.sanity_flood_control.clear_events();
client.second.flood_control_online.clear_events();
client_loop(client.second);
}
Expand Down Expand Up @@ -879,6 +883,9 @@ void ConnectionCreator::client_loop(ClientInfo &client) {
return client_set_timeout_at(client, wakeup_at);
}
client.sanity_flood_control.add_event(static_cast<int32>(Time::now()));
if (!act_as_if_online) {
client.backoff.add_event(static_cast<int32>(Time::now()));
}

// Create new RawConnection
// sync part
Expand All @@ -895,9 +902,6 @@ void ConnectionCreator::client_loop(ClientInfo &client) {

// Events with failed socket creation are ignored
flood_control.add_event(static_cast<int32>(Time::now()));
if (!act_as_if_online) {
client.backoff.add_event(static_cast<int32>(Time::now()));
}

auto socket_fd = r_socket_fd.move_as_ok();
IPAddress debug_ip;
Expand Down
2 changes: 1 addition & 1 deletion tdactor/td/actor/impl/Scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ void Scheduler::do_event(ActorInfo *actor_info, Event &&event) {
UNREACHABLE();
break;
}
// can't clear event here. It may be already destroyed during destory_actor
// can't clear event here. It may be already destroyed during destroy_actor
}

void Scheduler::register_migrated_actor(ActorInfo *actor_info) {
Expand Down

0 comments on commit c5059bc

Please sign in to comment.