From f0b48249242389766de521de0b2cec300f99872a Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 4 Oct 2022 21:08:07 +0300 Subject: [PATCH] Allow to start OptionManager on any scheduler. --- td/telegram/OptionManager.cpp | 7 +++++-- td/telegram/OptionManager.h | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/td/telegram/OptionManager.cpp b/td/telegram/OptionManager.cpp index da5bd959b..29ca76999 100644 --- a/td/telegram/OptionManager.cpp +++ b/td/telegram/OptionManager.cpp @@ -47,7 +47,10 @@ namespace td { OptionManager::OptionManager(Td *td) - : td_(td), options_(td::make_unique()), option_pmc_(G()->td_db()->get_config_pmc_shared()) { + : td_(td) + , current_scheduler_id_(Scheduler::instance()->sched_id()) + , options_(td::make_unique()) + , option_pmc_(G()->td_db()->get_config_pmc_shared()) { send_unix_time_update(); auto all_options = option_pmc_->get_all(); @@ -181,7 +184,7 @@ string OptionManager::get_option_string(Slice name, string default_value) const void OptionManager::set_option(Slice name, Slice value) { CHECK(!name.empty()); - CHECK(Scheduler::instance()->sched_id() == 0); + CHECK(Scheduler::instance()->sched_id() == current_scheduler_id_); if (value.empty()) { if (option_pmc_->erase(name.str()) == 0) { return; diff --git a/td/telegram/OptionManager.h b/td/telegram/OptionManager.h index dd79d4b80..69e548fb6 100644 --- a/td/telegram/OptionManager.h +++ b/td/telegram/OptionManager.h @@ -86,6 +86,7 @@ class OptionManager { bool is_td_inited_ = false; vector>>> pending_get_options_; + int32 current_scheduler_id_ = -1; unique_ptr options_; std::shared_ptr option_pmc_;