Resend requests on CONNECTION_NOT_INITED and CONNECTION_LAYER_INVALID errors.
This commit is contained in:
parent
5d58734568
commit
822257b90a
@ -169,14 +169,18 @@ class AuthData {
|
||||
|
||||
void on_api_response() {
|
||||
if (use_pfs()) {
|
||||
if (tmp_auth_key_.auth_flag()) {
|
||||
tmp_auth_key_.remove_header();
|
||||
}
|
||||
} else {
|
||||
if (main_auth_key_.auth_flag()) {
|
||||
main_auth_key_.remove_header();
|
||||
}
|
||||
}
|
||||
|
||||
void on_connection_not_inited() {
|
||||
if (use_pfs()) {
|
||||
tmp_auth_key_.restore_header();
|
||||
} else {
|
||||
main_auth_key_.restore_header();
|
||||
}
|
||||
}
|
||||
|
||||
void set_session_id(uint64 session_id) {
|
||||
|
@ -42,11 +42,14 @@ class AuthKey {
|
||||
return have_header_ || Time::now() < header_expires_at_;
|
||||
}
|
||||
void remove_header() {
|
||||
if (have_header_) {
|
||||
if (auth_flag_ && have_header_) {
|
||||
have_header_ = false;
|
||||
header_expires_at_ = Time::now() + 3;
|
||||
}
|
||||
}
|
||||
void restore_header() {
|
||||
have_header_ = true;
|
||||
}
|
||||
|
||||
double expires_at() const {
|
||||
return expires_at_;
|
||||
|
@ -956,6 +956,7 @@ void SessionConnection::flush_packet() {
|
||||
std::any_of(queries.begin(), queries.end(), [](const auto &query) { return query.use_quick_ack; });
|
||||
|
||||
{
|
||||
// LOG(ERROR) << (auth_data_->get_header().empty() ? '-' : '+');
|
||||
uint64 parent_message_id = 0;
|
||||
auto storer = PacketStorer<CryptoImpl>(
|
||||
queries, auth_data_->get_header(), std::move(to_ack), ping_id, ping_disconnect_delay() + 2, max_delay,
|
||||
|
@ -839,9 +839,14 @@ void Session::on_message_result_error(uint64 id, int error_code, string message)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (error_code == 400 && (message == "CONNECTION_NOT_INITED" || message == "CONNECTION_LAYER_INVALID")) {
|
||||
LOG(WARNING) << "Receive " << message;
|
||||
auth_data_.on_connection_not_inited();
|
||||
error_code = 500;
|
||||
}
|
||||
|
||||
if (id == 0) {
|
||||
LOG(WARNING) << "Session got error update";
|
||||
LOG(ERROR) << "Received an error update";
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user