diff --git a/src/pika_admin.cc b/src/pika_admin.cc index 2230dc8b3d..d0d056a286 100644 --- a/src/pika_admin.cc +++ b/src/pika_admin.cc @@ -95,6 +95,7 @@ void SlaveofCmd::Do() { if (is_noone_) { res_.SetRes(CmdRes::kOk); + g_pika_conf->SetSlaveof(std::string()); return; } diff --git a/src/pika_conf.cc b/src/pika_conf.cc index 59af247531..a91c74d642 100644 --- a/src/pika_conf.cc +++ b/src/pika_conf.cc @@ -355,11 +355,19 @@ int PikaConf::ConfigRewrite() { } if (!diff_commands_.empty()) { - slash::BaseConf::Rep::ConfItem item(slash::BaseConf::Rep::kComment, "# Generated by CONFIG REWRITE\n"); - PushConfItem(item); + std::vector filtered_items; for (const auto& diff_command : diff_commands_) { - slash::BaseConf::Rep::ConfItem item(slash::BaseConf::Rep::kConf, diff_command.first, diff_command.second); - PushConfItem(item); + if (!diff_command.second.empty()) { + slash::BaseConf::Rep::ConfItem item(slash::BaseConf::Rep::kConf, diff_command.first, diff_command.second); + filtered_items.push_back(item); + } + } + if (!filtered_items.empty()) { + slash::BaseConf::Rep::ConfItem comment_item(slash::BaseConf::Rep::kComment, "# Generated by CONFIG REWRITE\n"); + PushConfItem(comment_item); + for (const auto& item : filtered_items) { + PushConfItem(item); + } } RWLock l(&rwlock_, true); diff_commands_.clear();