From 42af033421a7233da697d438243ef986945fd015 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Fri, 25 May 2018 20:37:33 -0700 Subject: [PATCH] modules/s_conf: Provide linkage for conf "rehash" w/ console cmd. --- modules/console.cc | 17 +++++++++++++++++ modules/s_conf.cc | 21 ++++++++++++++++----- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/modules/console.cc b/modules/console.cc index c4147c878..bb16d6ace 100644 --- a/modules/console.cc +++ b/modules/console.cc @@ -631,6 +631,23 @@ console_cmd__conf__get(opt &out, const string_view &line) }; } +bool +console_cmd__conf__rehash(opt &out, const string_view &line) +{ + using prototype = void (); + static m::import rehash_conf + { + "s_conf", "rehash_conf" + }; + + rehash_conf(); + out << "Updated any runtime conf items" + << " from the current state in !conf:" << my_host() + << std::endl; + + return true; +} + // // hook // diff --git a/modules/s_conf.cc b/modules/s_conf.cc index 1e6b26669..f19dd73a4 100644 --- a/modules/s_conf.cc +++ b/modules/s_conf.cc @@ -10,10 +10,15 @@ using namespace ircd; +extern "C" void rehash_conf(); + mapi::header IRCD_MODULE { - "Server Configuration" + "Server Configuration", [] + { + rehash_conf(); + } }; const m::room::id::buf @@ -56,7 +61,7 @@ get_conf_item(const string_view &key, } static void -update_conf(const m::event &event) +conf_updated(const m::event &event) noexcept try { const auto &content @@ -92,9 +97,9 @@ catch(const std::exception &e) } const m::hook -update_conf_hook +conf_updated_hook { - update_conf, + conf_updated, { { "_site", "vm.notify" }, { "room_id", "!conf" }, @@ -113,7 +118,7 @@ init_conf_items(const m::event &) state.for_each("ircd.conf.item", [] (const m::event &event) { - update_conf(event); + conf_updated(event); }); } @@ -130,6 +135,12 @@ init_conf_items_hook } }; +void +rehash_conf() +{ + init_conf_items(m::event{}); +} + static void create_conf_item(const string_view &key, const conf::item<> &item)