Add current_time to on_pong.

This commit is contained in:
levlam 2024-06-21 17:06:20 +03:00
parent 1c98c0011a
commit 70adbbb9f6
5 changed files with 10 additions and 7 deletions

View File

@ -134,7 +134,7 @@ class PingConnectionPingPong final
void on_container_sent(MessageId container_message_id, vector<MessageId> message_ids) final {
}
Status on_pong(double ping_time, double pong_time) final {
Status on_pong(double ping_time, double pong_time, double current_time) final {
pong_cnt_++;
if (pong_cnt_ == 1) {
rtt_ = Time::now();

View File

@ -428,7 +428,8 @@ Status SessionConnection::on_packet(const MsgInfo &info, const mtproto_api::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_));
return callback_->on_pong(get_time(pong.ping_id_), get_time(pong.msg_id_),
auth_data_->get_server_time(Time::now_cached()));
}
Status SessionConnection::on_packet(const MsgInfo &info, const mtproto_api::future_salts &salts) {

View File

@ -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(double ping_time, double pong_time) = 0;
virtual Status on_pong(double ping_time, double pong_time, double current_time) = 0;
virtual Status on_update(BufferSlice packet) = 0;

View File

@ -565,7 +565,7 @@ void Session::on_connected() {
}
}
Status Session::on_pong(double ping_time, double pong_time) {
Status Session::on_pong(double ping_time, double pong_time, double current_time) {
constexpr int MAX_QUERY_TIMEOUT = 60;
constexpr int MIN_CONNECTION_ACTIVE = 60;
if (current_info_ == &main_connection_ &&
@ -575,7 +575,8 @@ Status Session::on_pong(double ping_time, double pong_time) {
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_)
<< " after ping sent at " << ping_time << " and answered at " << pong_time);
<< " after ping sent at " << ping_time << " and answered at " << pong_time
<< " with the current server time " << current_time);
}
if (!sent_queries_list_.empty()) {
for (auto it = sent_queries_list_.prev; it != &sent_queries_list_; it = it->prev) {
@ -585,7 +586,8 @@ Status Session::on_pong(double ping_time, double pong_time) {
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);
<< " after ping sent at " << ping_time << " and answered at " << pong_time
<< " with the current server time " << current_time);
}
query->is_acknowledged_ = false;
} else {

View File

@ -208,7 +208,7 @@ class Session final
void on_connected() final;
void on_closed(Status status) final;
Status on_pong(double ping_time, double pong_time) final;
Status on_pong(double ping_time, double pong_time, double current_time) final;
void on_network(bool network_flag, uint32 network_generation);
void on_online(bool online_flag);