SessionConnection: fix requesting of salt when Time::now() is close to zero

GitOrigin-RevId: cc585b4f8a5895964c24e947f855cc9248883961
This commit is contained in:
Arseny Smirnov 2018-09-04 17:01:01 +03:00
parent cab28f2cc8
commit 84429d0617

View File

@ -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;
}