From 84429d061767f5b0d25416caa0f62d52ce57a3f8 Mon Sep 17 00:00:00 2001 From: Arseny Smirnov Date: Tue, 4 Sep 2018 17:01:01 +0300 Subject: [PATCH] SessionConnection: fix requesting of salt when Time::now() is close to zero GitOrigin-RevId: cc585b4f8a5895964c24e947f855cc9248883961 --- td/mtproto/SessionConnection.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/td/mtproto/SessionConnection.cpp b/td/mtproto/SessionConnection.cpp index 862e081ae..f7bd4d74f 100644 --- a/td/mtproto/SessionConnection.cpp +++ b/td/mtproto/SessionConnection.cpp @@ -603,6 +603,9 @@ bool SessionConnection::must_flush_packet() { } // get_future_salt if (!has_salt) { + if (last_get_future_salt_at_ == 0) { + return true; + } auto get_future_salts_at = last_get_future_salt_at_ + 60; if (get_future_salts_at < Time::now_cached()) { return true; @@ -811,7 +814,8 @@ void SessionConnection::flush_packet() { // future salts int future_salt_n = 0; if (mode_ != Mode::HttpLongPoll) { - if (auth_data_->need_future_salts(Time::now_cached()) && last_get_future_salt_at_ + 60 < Time::now_cached()) { + if (auth_data_->need_future_salts(Time::now_cached()) && + (last_get_future_salt_at_ == 0 || last_get_future_salt_at_ + 60 < Time::now_cached())) { last_get_future_salt_at_ = Time::now_cached(); future_salt_n = 64; }