Skip to content

Commit

Permalink
config rewrite discard dynamically set a configuration which value is…
Browse files Browse the repository at this point in the history
… empty (#455)
  • Loading branch information
Axlgrep authored Dec 28, 2018
1 parent aa9a6a4 commit 97a7526
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/pika_admin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ void SlaveofCmd::Do() {

if (is_noone_) {
res_.SetRes(CmdRes::kOk);
g_pika_conf->SetSlaveof(std::string());
return;
}

Expand Down
16 changes: 12 additions & 4 deletions src/pika_conf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<slash::BaseConf::Rep::ConfItem> 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();
Expand Down

0 comments on commit 97a7526

Please sign in to comment.