Add more logging in to_unix_time.

GitOrigin-RevId: 1e191c31e4be4a29584844f27b098a21811daffd
This commit is contained in:
levlam 2020-02-22 19:31:08 +03:00
parent 04a002d9f3
commit c5f3b2223c
2 changed files with 9 additions and 3 deletions

View File

@ -102,6 +102,9 @@ Status Global::init(const TdParameters &parameters, ActorId<Td> td, unique_ptr<T
ServerTimeDiff saved_diff;
unserialize(saved_diff, saved_diff_str).ensure();
saved_diff_ = saved_diff.diff;
saved_system_time_ = saved_diff.system_time;
double diff = saved_diff.diff + default_time_difference;
if (saved_diff.system_time > system_time) {
double time_backwards_fix = saved_diff.system_time - system_time;
@ -129,8 +132,9 @@ Status Global::init(const TdParameters &parameters, ActorId<Td> td, unique_ptr<T
return Status::OK();
}
int32 Global::to_unix_time(double server_time) {
LOG_CHECK(1.0 <= server_time && server_time <= 2140000000.0) << server_time << " " << Clocks::system();
int32 Global::to_unix_time(double server_time) const {
LOG_CHECK(1.0 <= server_time && server_time <= 2140000000.0)
<< server_time << " " << Clocks::system() << " " << saved_diff_ << " " << saved_system_time_;
return static_cast<int32>(server_time);
}

View File

@ -398,6 +398,8 @@ class Global : public ActorContext {
std::atomic<bool> dns_time_difference_was_updated_{false};
std::atomic<bool> close_flag_{false};
std::atomic<double> system_time_saved_at_{-1e10};
double saved_diff_ = 0.0;
double saved_system_time_ = 0.0;
#if !TD_HAVE_ATOMIC_SHARED_PTR
std::mutex dh_config_mutex_;
@ -418,7 +420,7 @@ class Global : public ActorContext {
std::unordered_map<int64, int64> location_access_hashes_;
static int32 to_unix_time(double server_time);
int32 to_unix_time(double server_time) const;
void do_save_server_time_difference();