Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix slot may null #1712

Merged
merged 1 commit into from
Jul 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/pika_command.cc
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,11 @@ void Cmd::ProcessMultiSlotCmd() {
}
}

void Cmd::ProcessDoNotSpecifySlotCmd() { Do(); }
void Cmd::ProcessDoNotSpecifySlotCmd() {
std::shared_ptr<Slot> slot;
slot = g_pika_server->GetSlotByDBName(db_name_);
Do(slot);
}

bool Cmd::is_read() const { return ((flag_ & kCmdFlagsMaskRW) == kCmdFlagsRead); }
bool Cmd::is_write() const { return ((flag_ & kCmdFlagsMaskRW) == kCmdFlagsWrite); }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the provided code patch, here is a brief code review:

  1. In the ProcessDoNotSpecifySlotCmd() function, a shared pointer slot is created and initialized with the result of calling GetSlotByDBName() method on g_pika_server object.

    • Suggestion: Since slot is unused after this assignment, you may consider removing it and directly pass the result of GetSlotByDBName() to the Do() method.
  2. Assuming Do() method accepts a std::shared_ptr<Slot> as its argument, the change from Do() to Do(slot) in the ProcessDoNotSpecifySlotCmd() function seems appropriate and should work fine.

  3. The rest of the code snippet doesn't indicate any immediate bug risks or improvements.

Overall, the code modifications appear reasonable, but without further context or knowledge of the surrounding codebase, it's difficult to assess potential issues thoroughly. It's advisable to perform comprehensive testing to ensure the changes integrate correctly with the existing code and achieve the desired functionality.

Expand Down