diff --git a/td/mtproto/PingConnection.cpp b/td/mtproto/PingConnection.cpp index 7b74ee6ba..64a261501 100644 --- a/td/mtproto/PingConnection.cpp +++ b/td/mtproto/PingConnection.cpp @@ -134,7 +134,7 @@ class PingConnectionPingPong final void on_container_sent(MessageId container_message_id, vector 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(); diff --git a/td/mtproto/SessionConnection.cpp b/td/mtproto/SessionConnection.cpp index 70cb4fbe5..391785a6c 100644 --- a/td/mtproto/SessionConnection.cpp +++ b/td/mtproto/SessionConnection.cpp @@ -428,7 +428,8 @@ Status SessionConnection::on_packet(const MsgInfo &info, const mtproto_api::pong auto get_time = [](int64 msg_id) { return static_cast(msg_id) / (static_cast(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) { diff --git a/td/mtproto/SessionConnection.h b/td/mtproto/SessionConnection.h index ea633d60f..6515c543f 100644 --- a/td/mtproto/SessionConnection.h +++ b/td/mtproto/SessionConnection.h @@ -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 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; diff --git a/td/telegram/net/Session.cpp b/td/telegram/net/Session.cpp index 3ebf8f5ec..4077b6c5b 100644 --- a/td/telegram/net/Session.cpp +++ b/td/telegram/net/Session.cpp @@ -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 { diff --git a/td/telegram/net/Session.h b/td/telegram/net/Session.h index 803eb1116..8572757bb 100644 --- a/td/telegram/net/Session.h +++ b/td/telegram/net/Session.h @@ -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);