Skip to content

Commit

Permalink
fix rewire config program crash (OpenAtomFoundation#1339)
Browse files Browse the repository at this point in the history
  • Loading branch information
lqxhub authored Mar 14, 2023
1 parent cf16ae4 commit dcf4379
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/pika_admin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2101,9 +2101,12 @@ void ConfigCmd::ConfigSet(std::string& ret) {
}
}

void ConfigCmd::ConfigRewrite(std::string& ret) {
g_pika_conf->ConfigRewrite();
ret = "+OK\r\n";
void ConfigCmd::ConfigRewrite(std::string &ret) {
if (g_pika_conf->ConfigRewrite()) {
ret = "+OK\r\n";
} else {
ret = "-ERR Rewire CONFIG fail\r\n";
}
}

void ConfigCmd::ConfigResetstat(std::string& ret) {
Expand Down
3 changes: 3 additions & 0 deletions src/slash/src/base_conf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,9 @@ bool BaseConf::WriteBack() {
std::string tmp_path = rep_->path + ".tmp";
Status ret = NewWritableFile(tmp_path, &write_file);
log_info("ret %s", ret.ToString().c_str());
if (!write_file) {
return false;
}
std::string tmp;
for (size_t i = 0; i < rep_->item.size(); i++) {
if (rep_->item[i].type == Rep::kConf) {
Expand Down

0 comments on commit dcf4379

Please sign in to comment.