Skip to content

Commit

Permalink
fix: Changed multi and exec command initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
lankunGitHub committed Jan 17, 2025
1 parent 2e3b3d4 commit 020c099
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
Binary file modified dump.rdb
Binary file not shown.
12 changes: 7 additions & 5 deletions src/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

namespace kiwi {

extern kiwi::CmdTableManager cmd_table_manager_;
CmdTableManager cmd_table_manager;

const ClientInfo ClientInfo::invalidClientInfo = {0, "", -1};

Expand Down Expand Up @@ -335,7 +335,7 @@ bool PClient::Exec() {
this->ClearMulti();
this->ClearWatch();
};

DEBUG("Exec");
if (IsFlagOn(kClientFlagWrongExec)) {
return false;
}
Expand All @@ -346,14 +346,16 @@ bool PClient::Exec() {
return true;
}
resp_encode_->ClearReply();
DEBUG("size : {}", queue_cmds_.size());
AppendArrayLen(queue_cmds_.size());

DEBUG("judge");
auto client = shared_from_this();
cmd_table_manager.InitCmdTable();
for (auto& cmd : queue_cmds_) {
SetCmdName(kstd::StringToLower(cmd[0]));
SetArgv(cmd);
kstd::StringToLower(client->cmdName_);
auto [cmdPtr, ret] = cmd_table_manager_.GetCommand(client->CmdName(), client.get());
auto [cmdPtr, ret] = cmd_table_manager.GetCommand(client->CmdName(), client.get());

auto cmdstat_map = GetCommandStatMap();
CommandStatistics statistics;
Expand All @@ -372,7 +374,7 @@ bool PClient::Exec() {

FeedMonitors(cmd);
}

DEBUG("over");
g_kiwi->PushWriteTask(client);
// Propagate(client->params_, GetCurrentDB());
return true;
Expand Down
4 changes: 4 additions & 0 deletions src/cmd_table_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ CmdTableManager::CmdTableManager() {
void CmdTableManager::InitCmdTable() {
std::unique_lock wl(mutex_);

if (cmds_->size() != 0) {
return;
}

// admin
ADD_COMMAND_GROUP(Config, -2);
ADD_SUBCOMMAND(Config, Get, -3);
Expand Down
10 changes: 2 additions & 8 deletions src/transaction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,7 @@ void UnWatchCmd::DoCmd(PClient* client) {
MultiCmd::MultiCmd(const std::string& name, int16_t arity)
: BaseCmd(name, arity, kCmdFlagsReadonly, kAclCategoryRead | kAclCategoryTransaction) {}

bool MultiCmd::DoInitial(PClient* client) {
client->SetKey(client->argv_[1]);
return true;
}
bool MultiCmd::DoInitial(PClient* client) { return true; }

void MultiCmd::DoCmd(PClient* client) {
if (PTransaction::Instance().Multi(client)) {
Expand All @@ -165,10 +162,7 @@ void MultiCmd::DoCmd(PClient* client) {
ExecCmd::ExecCmd(const std::string& name, int16_t arity)
: BaseCmd(name, arity, kCmdFlagsReadonly, kAclCategoryRead | kAclCategoryTransaction) {}

bool ExecCmd::DoInitial(PClient* client) {
client->SetKey(client->argv_[1]);
return true;
}
bool ExecCmd::DoInitial(PClient* client) { return true; }

void ExecCmd::DoCmd(PClient* client) {
if (!client->IsFlagOn(kClientFlagMulti)) {
Expand Down

0 comments on commit 020c099

Please sign in to comment.