Fixes for system_time_saved_at_.

GitOrigin-RevId: 1effe236b00a00facfec0d6492bd60fe52faa737
This commit is contained in:
levlam 2019-12-25 18:03:08 +03:00
parent 41b09d9c31
commit bd559bf13a
2 changed files with 3 additions and 3 deletions

View File

@ -93,7 +93,7 @@ Status Global::init(const TdParameters &parameters, ActorId<Td> td, unique_ptr<T
td_db_ = std::move(td_db_ptr);
string saved_diff_str = td_db()->get_binlog_pmc()->get("server_time_difference");
auto system_time = Clocks::system();
auto system_time = max(1577285000.0, Clocks::system());
auto default_time_difference = system_time - Time::now();
if (saved_diff_str.empty()) {
server_time_difference_ = default_time_difference;
@ -128,7 +128,7 @@ void Global::update_server_time_difference(double diff) {
void Global::save_server_time() {
auto t = Time::now();
if (system_time_saved_at_.load(std::memory_order_relaxed) + 10 < t) {
if (server_time_difference_was_updated_ && system_time_saved_at_.load(std::memory_order_relaxed) + 10 < t) {
system_time_saved_at_ = t;
do_save_server_time_difference();
}

View File

@ -409,7 +409,7 @@ class Global : public ActorContext {
std::atomic<double> dns_time_difference_{0.0};
std::atomic<bool> dns_time_difference_was_updated_{false};
std::atomic<bool> close_flag_{false};
std::atomic<double> system_time_saved_at_{0.0};
std::atomic<double> system_time_saved_at_{-1e10};
std::vector<std::shared_ptr<NetStatsCallback>> net_stats_file_callbacks_;