Add ping_time and pong_time to error message.
This commit is contained in:
parent
015f8cdd8f
commit
d2d7cc2fe1
@ -134,7 +134,7 @@ class PingConnectionPingPong final
|
||||
void on_container_sent(MessageId container_message_id, vector<MessageId> message_ids) final {
|
||||
}
|
||||
|
||||
Status on_pong() final {
|
||||
Status on_pong(double ping_time, double pong_time) final {
|
||||
pong_cnt_++;
|
||||
if (pong_cnt_ == 1) {
|
||||
rtt_ = Time::now();
|
||||
|
@ -425,7 +425,10 @@ Status SessionConnection::on_packet(const MsgInfo &info, const mtproto_api::pong
|
||||
|
||||
last_pong_at_ = Time::now_cached();
|
||||
real_last_pong_at_ = last_pong_at_;
|
||||
return callback_->on_pong();
|
||||
auto get_time = [](int64 msg_id) {
|
||||
return static_cast<double>(msg_id) / (static_cast<uint64>(1) << 32);
|
||||
};
|
||||
return callback_->on_pong(get_time(pong.ping_id_), get_time(pong.msg_id_));
|
||||
}
|
||||
|
||||
Status SessionConnection::on_packet(const MsgInfo &info, const mtproto_api::future_salts &salts) {
|
||||
|
@ -98,7 +98,7 @@ class SessionConnection final
|
||||
virtual void on_session_failed(Status status) = 0;
|
||||
|
||||
virtual void on_container_sent(MessageId container_message_id, vector<MessageId> message_ids) = 0;
|
||||
virtual Status on_pong() = 0;
|
||||
virtual Status on_pong(double ping_time, double pong_time) = 0;
|
||||
|
||||
virtual Status on_update(BufferSlice packet) = 0;
|
||||
|
||||
|
@ -565,7 +565,7 @@ void Session::on_connected() {
|
||||
}
|
||||
}
|
||||
|
||||
Status Session::on_pong() {
|
||||
Status Session::on_pong(double ping_time, double pong_time) {
|
||||
constexpr int MAX_QUERY_TIMEOUT = 60;
|
||||
constexpr int MIN_CONNECTION_ACTIVE = 60;
|
||||
if (current_info_ == &main_connection_ &&
|
||||
@ -574,16 +574,18 @@ Status Session::on_pong() {
|
||||
if (!unknown_queries_.empty()) {
|
||||
status = Status::Error(PSLICE() << "No state info for " << unknown_queries_.size() << " queries from auth key "
|
||||
<< auth_data_.get_auth_key().id() << " for "
|
||||
<< format::as_time(Time::now() - current_info_->created_at_));
|
||||
<< format::as_time(Time::now() - current_info_->created_at_)
|
||||
<< " after ping sent at " << ping_time << " and answered at " << pong_time);
|
||||
}
|
||||
if (!sent_queries_list_.empty()) {
|
||||
for (auto it = sent_queries_list_.prev; it != &sent_queries_list_; it = it->prev) {
|
||||
auto query = Query::from_list_node(it);
|
||||
if (Timestamp::at(query->sent_at_ + MAX_QUERY_TIMEOUT).is_in_past()) {
|
||||
if (status.is_ok()) {
|
||||
status = Status::Error(PSLICE()
|
||||
<< "No answer from auth key " << auth_data_.get_auth_key().id() << " for "
|
||||
<< query->net_query_ << " for " << format::as_time(Time::now() - query->sent_at_));
|
||||
status =
|
||||
Status::Error(PSLICE() << "No answer from auth key " << auth_data_.get_auth_key().id() << " for "
|
||||
<< query->net_query_ << " for " << format::as_time(Time::now() - query->sent_at_)
|
||||
<< " after ping sent at " << ping_time << " and answered at " << pong_time);
|
||||
}
|
||||
query->is_acknowledged_ = false;
|
||||
} else {
|
||||
|
@ -208,7 +208,7 @@ class Session final
|
||||
void on_connected() final;
|
||||
void on_closed(Status status) final;
|
||||
|
||||
Status on_pong() final;
|
||||
Status on_pong(double ping_time, double pong_time) final;
|
||||
|
||||
void on_network(bool network_flag, uint32 network_generation);
|
||||
void on_online(bool online_flag);
|
||||
|
Loading…
Reference in New Issue
Block a user