Remove unneded UpdatesManager::get_state.
GitOrigin-RevId: d95a262233bd5959950eab8159a589a689d8a4b5
This commit is contained in:
parent
044a3a6f14
commit
e9bb986d9c
@ -6688,7 +6688,7 @@ void MessagesManager::after_get_difference() {
|
||||
}
|
||||
|
||||
LOG(ERROR) << "Receive updateMessageId from " << it.second << " to " << it.first
|
||||
<< " but not receive corresponding message. " << td_->updates_manager_->get_state();
|
||||
<< " but not receive corresponding message";
|
||||
if (dialog_id.get_type() != DialogType::Channel) {
|
||||
dump_debug_message_op(get_dialog(dialog_id));
|
||||
}
|
||||
@ -8347,7 +8347,7 @@ void MessagesManager::read_history_inbox(DialogId dialog_id, MessageId max_messa
|
||||
dialog_id.get_type() != DialogType::Channel && !running_get_difference_)
|
||||
<< "Receive read inbox update up to unknown " << max_message_id << " in " << dialog_id << " from " << source
|
||||
<< ". Last new is " << d->last_new_message_id << ", unread_count = " << unread_count
|
||||
<< ". Possible only for deleted incoming message. " << td_->updates_manager_->get_state();
|
||||
<< ". Possible only for deleted incoming message";
|
||||
|
||||
if (dialog_id.get_type() == DialogType::SecretChat) {
|
||||
ttl_read_history(d, false, max_message_id, d->last_read_inbox_message_id, Time::now());
|
||||
@ -8413,8 +8413,7 @@ void MessagesManager::read_history_outbox(DialogId dialog_id, MessageId max_mess
|
||||
LOG_IF(INFO, d->last_new_message_id.is_valid() && max_message_id.get() > d->last_new_message_id.get() &&
|
||||
dialog_id.get_type() != DialogType::Channel)
|
||||
<< "Receive read outbox update about unknown " << max_message_id << " in " << dialog_id << " with last new "
|
||||
<< d->last_new_message_id << ". Possible only for deleted outgoing message. "
|
||||
<< td_->updates_manager_->get_state();
|
||||
<< d->last_new_message_id << ". Possible only for deleted outgoing message";
|
||||
|
||||
if (dialog_id.get_type() == DialogType::SecretChat) {
|
||||
double server_time = Time::now();
|
||||
@ -19830,8 +19829,7 @@ FullMessageId MessagesManager::on_send_message_success(int64 random_id, MessageI
|
||||
auto it = being_sent_messages_.find(random_id);
|
||||
if (it == being_sent_messages_.end()) {
|
||||
LOG(ERROR) << "Result from sendMessage for " << new_message_id << " with random_id " << random_id << " sent at "
|
||||
<< date << " comes from " << source << " after updateNewMessageId, but was not discarded by pts. "
|
||||
<< td_->updates_manager_->get_state();
|
||||
<< date << " comes from " << source << " after updateNewMessageId, but was not discarded by pts";
|
||||
if (debug_being_sent_messages_.count(random_id) == 0) {
|
||||
LOG(ERROR) << "Message with random_id " << random_id << " was mot sent";
|
||||
return {};
|
||||
@ -19856,7 +19854,7 @@ FullMessageId MessagesManager::on_send_message_success(int64 random_id, MessageI
|
||||
<< (m->forward_info == nullptr ? " not" : "") << " forwarded " << new_message_id
|
||||
<< " with content of the type " << m->content->get_type() << " in " << dialog_id
|
||||
<< " comes after updateNewMessageId, current last new is " << d->last_new_message_id << ", last is "
|
||||
<< d->last_message_id << ". " << td_->updates_manager_->get_state();
|
||||
<< d->last_message_id;
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -22373,8 +22371,7 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq
|
||||
LOG(ERROR) << "Receive again " << (message->is_outgoing ? "outgoing" : "incoming")
|
||||
<< (message->forward_info == nullptr ? " not" : "") << " forwarded " << message_id
|
||||
<< " with content of type " << message_content_type << " in " << dialog_id << " from " << source
|
||||
<< ", current last new is " << d->last_new_message_id << ", last is " << d->last_message_id << ". "
|
||||
<< td_->updates_manager_->get_state();
|
||||
<< ", current last new is " << d->last_new_message_id << ", last is " << d->last_message_id;
|
||||
dump_debug_message_op(d, 1);
|
||||
}
|
||||
}
|
||||
|
@ -187,52 +187,11 @@ void UpdatesManager::fill_gap(void *td, const char *source) {
|
||||
CHECK(td != nullptr);
|
||||
auto updates_manager = static_cast<Td *>(td)->updates_manager_.get();
|
||||
|
||||
LOG(WARNING) << "Filling gap in " << source << " by running getDifference. " << updates_manager->get_state();
|
||||
LOG(WARNING) << "Filling gap in " << source << " by running getDifference";
|
||||
|
||||
updates_manager->get_difference("fill_gap");
|
||||
}
|
||||
|
||||
string UpdatesManager::get_state() const {
|
||||
char buff[1024];
|
||||
StringBuilder sb(MutableSlice{buff, sizeof(buff)});
|
||||
sb << "UpdatesManager is in state ";
|
||||
switch (state_.type) {
|
||||
case State::Type::General:
|
||||
sb << "General";
|
||||
break;
|
||||
case State::Type::RunningGetUpdatesState:
|
||||
sb << "RunningGetUpdatesState";
|
||||
break;
|
||||
case State::Type::RunningGetDifference:
|
||||
sb << "RunningGetDifference";
|
||||
break;
|
||||
case State::Type::ApplyingDifference:
|
||||
sb << "ApplyingDifference";
|
||||
break;
|
||||
case State::Type::ApplyingDifferenceSlice:
|
||||
sb << "ApplyingDifferenceSlice";
|
||||
break;
|
||||
case State::Type::ApplyingUpdates:
|
||||
sb << "ApplyingUpdates";
|
||||
break;
|
||||
case State::Type::ApplyingSeqUpdates:
|
||||
sb << "ApplyingSeqUpdates";
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
sb << " with pts = " << state_.pts << ", qts = " << state_.qts << " and date = " << state_.date;
|
||||
CHECK(!sb.is_error());
|
||||
return sb.as_cslice().str();
|
||||
}
|
||||
|
||||
void UpdatesManager::set_state(State::Type type) {
|
||||
state_.type = type;
|
||||
state_.pts = get_pts();
|
||||
state_.qts = qts_;
|
||||
state_.date = date_;
|
||||
}
|
||||
|
||||
void UpdatesManager::get_difference(const char *source) {
|
||||
if (get_pts() == -1) {
|
||||
init_state();
|
||||
@ -255,8 +214,6 @@ void UpdatesManager::get_difference(const char *source) {
|
||||
|
||||
td_->create_handler<GetDifferenceQuery>()->send();
|
||||
last_get_difference_pts_ = get_pts();
|
||||
|
||||
set_state(State::Type::RunningGetDifference);
|
||||
}
|
||||
|
||||
void UpdatesManager::before_get_difference(bool is_initial) {
|
||||
@ -302,7 +259,7 @@ Promise<> UpdatesManager::set_pts(int32 pts, const char *source) {
|
||||
Promise<> result;
|
||||
if (pts > get_pts() || (0 < pts && pts < get_pts() - 399999)) { // pts can only go up or drop cardinally
|
||||
if (pts < get_pts() - 399999) {
|
||||
LOG(WARNING) << "Pts decreases from " << get_pts() << " to " << pts << " from " << source << ". " << get_state();
|
||||
LOG(WARNING) << "Pts decreases from " << get_pts() << " to " << pts << " from " << source;
|
||||
} else {
|
||||
LOG(INFO) << "Update pts from " << get_pts() << " to " << pts << " from " << source;
|
||||
}
|
||||
@ -313,8 +270,7 @@ Promise<> UpdatesManager::set_pts(int32 pts, const char *source) {
|
||||
schedule_get_difference("set_pts");
|
||||
}
|
||||
} else if (pts < get_pts()) {
|
||||
LOG(ERROR) << "Receive wrong pts = " << pts << " from " << source << ". Current pts = " << get_pts() << ". "
|
||||
<< get_state();
|
||||
LOG(ERROR) << "Receive wrong pts = " << pts << " from " << source << ". Current pts = " << get_pts();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -326,7 +282,7 @@ void UpdatesManager::set_qts(int32 qts) {
|
||||
qts_ = qts;
|
||||
G()->td_db()->get_binlog_pmc()->set("updates.qts", to_string(qts));
|
||||
} else if (qts < qts_) {
|
||||
LOG(ERROR) << "Receive wrong qts = " << qts << ". Current qts = " << qts_ << ". " << get_state();
|
||||
LOG(ERROR) << "Receive wrong qts = " << qts << ". Current qts = " << qts_;
|
||||
}
|
||||
}
|
||||
|
||||
@ -362,7 +318,7 @@ void UpdatesManager::set_date(int32 date, bool from_update, string date_source)
|
||||
}
|
||||
}
|
||||
LOG(ERROR) << "Receive wrong by " << (date_ - date) << " date = " << date << " from " << date_source
|
||||
<< ". Current date = " << date_ << " from " << date_source_ << ". " << get_state();
|
||||
<< ". Current date = " << date_ << " from " << date_source_;
|
||||
}
|
||||
}
|
||||
|
||||
@ -919,8 +875,6 @@ void UpdatesManager::init_state() {
|
||||
before_get_difference(true);
|
||||
|
||||
td_->create_handler<GetUpdatesStateQuery>()->send();
|
||||
|
||||
set_state(State::Type::RunningGetUpdatesState);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -1014,8 +968,6 @@ void UpdatesManager::on_get_difference(tl_object_ptr<telegram_api::updates_Diffe
|
||||
td_->contacts_manager_->on_get_users(std::move(difference->users_), "updates.difference");
|
||||
td_->contacts_manager_->on_get_chats(std::move(difference->chats_), "updates.difference");
|
||||
|
||||
set_state(State::Type::ApplyingDifference);
|
||||
|
||||
process_get_difference_updates(std::move(difference->new_messages_),
|
||||
std::move(difference->new_encrypted_messages_), difference->state_->qts_,
|
||||
std::move(difference->other_updates_));
|
||||
@ -1039,8 +991,6 @@ void UpdatesManager::on_get_difference(tl_object_ptr<telegram_api::updates_Diffe
|
||||
td_->contacts_manager_->on_get_users(std::move(difference->users_), "updates.differenceSlice");
|
||||
td_->contacts_manager_->on_get_chats(std::move(difference->chats_), "updates.differenceSlice");
|
||||
|
||||
set_state(State::Type::ApplyingDifferenceSlice);
|
||||
|
||||
process_get_difference_updates(std::move(difference->new_messages_),
|
||||
std::move(difference->new_encrypted_messages_),
|
||||
difference->intermediate_state_->qts_, std::move(difference->other_updates_));
|
||||
@ -1073,7 +1023,6 @@ void UpdatesManager::on_get_difference(tl_object_ptr<telegram_api::updates_Diffe
|
||||
void UpdatesManager::after_get_difference() {
|
||||
CHECK(!running_get_difference_);
|
||||
send_closure(td_->secret_chats_manager_, &SecretChatsManager::after_get_difference);
|
||||
auto saved_state = state_;
|
||||
|
||||
retry_timeout_.cancel_timeout();
|
||||
retry_time_ = 1;
|
||||
@ -1102,8 +1051,6 @@ void UpdatesManager::after_get_difference() {
|
||||
VLOG(get_difference) << "Finish to apply postponed updates";
|
||||
}
|
||||
|
||||
state_ = saved_state;
|
||||
|
||||
td_->animations_manager_->after_get_difference();
|
||||
td_->contacts_manager_->after_get_difference();
|
||||
td_->inline_queries_manager_->after_get_difference();
|
||||
@ -1111,8 +1058,6 @@ void UpdatesManager::after_get_difference() {
|
||||
td_->stickers_manager_->after_get_difference();
|
||||
send_closure_later(td_->notification_manager_actor_, &NotificationManager::after_get_difference);
|
||||
send_closure(G()->state_manager(), &StateManager::on_synchronized, true);
|
||||
|
||||
set_state(State::Type::General);
|
||||
}
|
||||
|
||||
void UpdatesManager::on_pending_updates(vector<tl_object_ptr<telegram_api::Update>> &&updates, int32 seq_begin,
|
||||
@ -1186,8 +1131,6 @@ void UpdatesManager::on_pending_updates(vector<tl_object_ptr<telegram_api::Updat
|
||||
}
|
||||
}
|
||||
|
||||
set_state(State::Type::ApplyingUpdates);
|
||||
|
||||
if (date > 0 && updates.size() == 1 && updates[0] != nullptr &&
|
||||
updates[0]->get_id() == telegram_api::updateReadHistoryOutbox::ID) {
|
||||
auto update = static_cast<const telegram_api::updateReadHistoryOutbox *>(updates[0].get());
|
||||
@ -1243,8 +1186,6 @@ void UpdatesManager::on_pending_updates(vector<tl_object_ptr<telegram_api::Updat
|
||||
return;
|
||||
}
|
||||
|
||||
set_state(State::Type::General);
|
||||
|
||||
if (processed_updates == updates.size()) {
|
||||
if (seq_begin || seq_end) {
|
||||
LOG(ERROR) << "All updates from " << source << " was processed but seq = " << seq_
|
||||
@ -1327,8 +1268,6 @@ void UpdatesManager::process_updates(vector<tl_object_ptr<telegram_api::Update>>
|
||||
|
||||
void UpdatesManager::process_seq_updates(int32 seq_end, int32 date,
|
||||
vector<tl_object_ptr<telegram_api::Update>> &&updates) {
|
||||
set_state(State::Type::ApplyingSeqUpdates);
|
||||
|
||||
string serialized_updates = PSTRING() << "process_seq_updates [seq_ = " << seq_ << ", seq_end = " << seq_end << "]: ";
|
||||
// TODO remove after bugs will be fixed
|
||||
for (auto &update : updates) {
|
||||
@ -1343,10 +1282,6 @@ void UpdatesManager::process_seq_updates(int32 seq_end, int32 date,
|
||||
if (date && seq_end) {
|
||||
set_date(date, true, std::move(serialized_updates));
|
||||
}
|
||||
|
||||
if (!running_get_difference_) {
|
||||
set_state(State::Type::General);
|
||||
}
|
||||
}
|
||||
|
||||
void UpdatesManager::process_pending_seq_updates() {
|
||||
|
@ -67,8 +67,6 @@ class UpdatesManager : public Actor {
|
||||
return date_;
|
||||
}
|
||||
|
||||
string get_state() const; // for debug purposes only
|
||||
|
||||
Promise<> set_pts(int32 pts, const char *source) TD_WARN_UNUSED_RESULT;
|
||||
|
||||
void set_qts(int32 qts);
|
||||
@ -120,27 +118,6 @@ class UpdatesManager : public Actor {
|
||||
bool running_get_difference_ = false;
|
||||
int32 last_get_difference_pts_ = 0;
|
||||
|
||||
class State {
|
||||
public:
|
||||
enum class Type : int32 {
|
||||
General,
|
||||
RunningGetUpdatesState,
|
||||
RunningGetDifference,
|
||||
ApplyingDifference,
|
||||
ApplyingDifferenceSlice,
|
||||
ApplyingUpdates,
|
||||
ApplyingSeqUpdates
|
||||
};
|
||||
Type type = Type::General;
|
||||
int32 pts = -1;
|
||||
int32 qts = -1;
|
||||
int32 date = -1;
|
||||
};
|
||||
|
||||
State state_; // for debug purposes only
|
||||
|
||||
void set_state(State::Type type); // for debug purposes only
|
||||
|
||||
void tear_down() override;
|
||||
|
||||
Promise<> add_pts(int32 pts);
|
||||
|
Reference in New Issue
Block a user