Add td_db() debug.

GitOrigin-RevId: 7eaa8b1a09a97ea935b46144cf5f6ef48f04712b
This commit is contained in:
levlam 2019-04-08 01:09:54 +03:00
parent 99a27126e5
commit f8a807ba4f
2 changed files with 8 additions and 6 deletions

View File

@ -61,16 +61,16 @@ void Global::set_mtproto_header(unique_ptr<MtprotoHeader> mtproto_header) {
mtproto_header_ = std::move(mtproto_header);
}
Status Global::init(const TdParameters &parameters, ActorId<Td> td, unique_ptr<TdDb> td_db) {
Status Global::init(const TdParameters &parameters, ActorId<Td> td, unique_ptr<TdDb> td_db_ptr) {
parameters_ = parameters;
gc_scheduler_id_ = min(Scheduler::instance()->sched_id() + 2, Scheduler::instance()->sched_count() - 1);
slow_net_scheduler_id_ = min(Scheduler::instance()->sched_id() + 3, Scheduler::instance()->sched_count() - 1);
td_ = td;
td_db_ = std::move(td_db);
td_db_ = std::move(td_db_ptr);
string save_diff_str = this->td_db()->get_binlog_pmc()->get("server_time_difference");
string save_diff_str = td_db()->get_binlog_pmc()->get("server_time_difference");
if (save_diff_str.empty()) {
server_time_difference_ = Clocks::system() - Time::now();
server_time_difference_was_updated_ = false;

View File

@ -19,6 +19,7 @@
#include "td/net/NetStats.h"
#include "td/utils/common.h"
#include "td/utils/logging.h"
#include "td/utils/Slice.h"
#include "td/utils/Status.h"
#include "td/utils/Time.h"
@ -67,14 +68,15 @@ class Global : public ActorContext {
Global(Global &&other) = delete;
Global &operator=(Global &&other) = delete;
TdDb *td_db() {
CHECK(td_db_);
#define td_db() get_td_db_impl(__FILE__, __LINE__)
TdDb *get_td_db_impl(const char *file, int line) {
LOG_CHECK(td_db_) << close_flag() << " " << file << " " << line;
return td_db_.get();
}
void close_all(Promise<> on_finished);
void close_and_destroy_all(Promise<> on_finished);
Status init(const TdParameters &parameters, ActorId<Td> td, unique_ptr<TdDb> td_db) TD_WARN_UNUSED_RESULT;
Status init(const TdParameters &parameters, ActorId<Td> td, unique_ptr<TdDb> td_db_ptr) TD_WARN_UNUSED_RESULT;
Slice get_dir() const {
return parameters_.database_directory;