Skip to content

Commit

Permalink
fix-pointer (OpenAtomFoundation#1729)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mixficsol authored Jul 15, 2023
1 parent 355bb10 commit f5223b2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion include/pika_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ class PikaServer : public pstd::noncopyable {
/*
* Info Commandstats used
*/
std::unordered_map<std::string, CommandStatistics>& GetCommandStatMap();
std::unordered_map<std::string, CommandStatistics>* GetCommandStatMap();

friend class Cmd;
friend class InfoCmd;
Expand Down
2 changes: 1 addition & 1 deletion src/pika_admin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,7 @@ void InfoCmd::InfoCommandStats(std::string& info) {
tmp_stream.precision(2);
tmp_stream.setf(std::ios::fixed);
tmp_stream << "# Commandstats" << "\r\n";
for (auto& iter : g_pika_server->GetCommandStatMap()) {
for (auto& iter : *g_pika_server->GetCommandStatMap()) {
if (iter.second.cmd_count != 0) {
tmp_stream << "cmdstat_" << iter.first << ":"
<< "calls=" << iter.second.cmd_count << ",usec="
Expand Down
6 changes: 3 additions & 3 deletions src/pika_client_conn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ std::shared_ptr<Cmd> PikaClientConn::DoCmd(const PikaCmdArgsType& argv, const st
// Process Command
c_ptr->Execute();
uint64_t duration = pstd::NowMicros() - start_us;
auto &cmdstat_map = g_pika_server->GetCommandStatMap();
cmdstat_map[opt].cmd_count.fetch_add(1);
cmdstat_map[opt].cmd_time_consuming.fetch_add(duration);
auto cmdstat_map = g_pika_server->GetCommandStatMap();
(*cmdstat_map)[opt].cmd_count.fetch_add(1);
(*cmdstat_map)[opt].cmd_time_consuming.fetch_add(duration);

if (g_pika_conf->slowlog_slower_than() >= 0) {
ProcessSlowlog(argv, start_us, c_ptr->GetDoDuration());
Expand Down
6 changes: 3 additions & 3 deletions src/pika_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void PikaServer::Start() {
}
}
CommandStatistics statistics;
auto &cmdstat_map = g_pika_server->GetCommandStatMap();
auto cmdstat_map = *g_pika_server->GetCommandStatMap();
for (auto& iter : *g_pika_cmd_table_manager->GetCmdTable()) {
cmdstat_map.emplace(iter.first, statistics);
}
Expand Down Expand Up @@ -1603,8 +1603,8 @@ void PikaServer::Bgslotsreload(const std::shared_ptr<Slot>& slot) {
bgsave_thread_.Schedule(&DoBgslotsreload, static_cast<void*>(this));
}

std::unordered_map<std::string, CommandStatistics>& PikaServer::GetCommandStatMap() {
return cmdstat_map_;
std::unordered_map<std::string, CommandStatistics>* PikaServer::GetCommandStatMap() {
return &cmdstat_map_;
}

void DoBgslotsreload(void* arg) {
Expand Down

0 comments on commit f5223b2

Please sign in to comment.