Improve handling of new_session_created.
This commit is contained in:
parent
55e5b2395e
commit
ba0d2408f2
@ -122,7 +122,7 @@ class PingConnectionPingPong final
|
||||
void on_server_time_difference_updated(bool force) final {
|
||||
}
|
||||
|
||||
void on_session_created(uint64 unique_id, uint64 first_id) final {
|
||||
void on_new_session_created(uint64 unique_id, uint64 first_id) final {
|
||||
}
|
||||
void on_session_failed(Status status) final {
|
||||
}
|
||||
|
@ -306,7 +306,7 @@ Status SessionConnection::on_packet(const MsgInfo &info, const mtproto_api::new_
|
||||
VLOG(mtproto) << "NEW_SESSION_CREATED: [first_msg_id:" << format::as_hex(new_session_created.first_msg_id_)
|
||||
<< "] [unique_id:" << format::as_hex(new_session_created.unique_id_)
|
||||
<< "] [server_salt:" << format::as_hex(new_session_created.server_salt_) << "]";
|
||||
callback_->on_session_created(new_session_created.unique_id_, new_session_created.first_msg_id_);
|
||||
callback_->on_new_session_created(new_session_created.unique_id_, new_session_created.first_msg_id_);
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ class SessionConnection final
|
||||
virtual void on_server_salt_updated() = 0;
|
||||
virtual void on_server_time_difference_updated(bool force) = 0;
|
||||
|
||||
virtual void on_session_created(uint64 unique_id, uint64 first_id) = 0;
|
||||
virtual void on_new_session_created(uint64 unique_id, uint64 first_id) = 0;
|
||||
virtual void on_session_failed(Status status) = 0;
|
||||
|
||||
virtual void on_container_sent(uint64 container_id, vector<uint64> msgs_id) = 0;
|
||||
|
@ -700,8 +700,7 @@ void Session::on_closed(Status status) {
|
||||
current_info_->state_ = ConnectionInfo::State::Empty;
|
||||
}
|
||||
|
||||
void Session::on_session_created(uint64 unique_id, uint64 first_message_id) {
|
||||
// TODO: use unique_id
|
||||
void Session::on_new_session_created(uint64 unique_id, uint64 first_message_id) {
|
||||
LOG(INFO) << "New session " << unique_id << " created with first message_id " << first_message_id;
|
||||
if (!use_pfs_ && !auth_data_.use_pfs()) {
|
||||
last_success_timestamp_ = Time::now();
|
||||
@ -713,16 +712,22 @@ void Session::on_session_created(uint64 unique_id, uint64 first_message_id) {
|
||||
last_activity_timestamp_ = Time::now();
|
||||
callback_->on_update(std::move(packet), auth_data_.get_auth_key().id());
|
||||
}
|
||||
|
||||
auto first_query_it = sent_queries_.find(first_message_id);
|
||||
if (first_query_it != sent_queries_.end()) {
|
||||
first_message_id = first_query_it->second.container_message_id_;
|
||||
LOG(INFO) << "Update first_message_id to container's " << first_message_id;
|
||||
} else {
|
||||
LOG(ERROR) << "Failed to find query " << first_message_id << " from the new session";
|
||||
}
|
||||
for (auto it = sent_queries_.begin(); it != sent_queries_.end();) {
|
||||
Query *query_ptr = &it->second;
|
||||
if (query_ptr->container_message_id_ < first_message_id) {
|
||||
// container vector leak otherwise
|
||||
cleanup_container(it->first, &it->second);
|
||||
mark_as_known(it->first, &it->second);
|
||||
cleanup_container(it->first, query_ptr);
|
||||
mark_as_known(it->first, query_ptr);
|
||||
|
||||
auto &query = it->second.net_query_;
|
||||
VLOG(net_query) << "Resend query (on_session_created) " << query;
|
||||
auto &query = query_ptr->net_query_;
|
||||
VLOG(net_query) << "Resend from on_new_session_created " << query;
|
||||
query->set_message_id(0);
|
||||
query->cancel_slot_.clear_event();
|
||||
resend_query(std::move(query));
|
||||
|
@ -214,7 +214,7 @@ class Session final
|
||||
void on_server_salt_updated() final;
|
||||
void on_server_time_difference_updated(bool force) final;
|
||||
|
||||
void on_session_created(uint64 unique_id, uint64 first_message_id) final;
|
||||
void on_new_session_created(uint64 unique_id, uint64 first_message_id) final;
|
||||
void on_session_failed(Status status) final;
|
||||
|
||||
void on_container_sent(uint64 container_message_id, vector<uint64> message_ids) final;
|
||||
|
Loading…
Reference in New Issue
Block a user