Skip to content

Commit

Permalink
Modify the function return value,rename function name
Browse files Browse the repository at this point in the history
  • Loading branch information
lqxhub committed Nov 13, 2023
1 parent f5362b7 commit 3b07dbe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ int PClient::handlePacket(const char* start, int bytes) {
// const PCommandInfo* info = PCommandTable::GetCommandInfo(cmdName_);

// if (!info) { // 如果这个命令不存在,那么就走新的命令处理流程
handlePacketNew();
executeCommand();
// return static_cast<int>(ptr - start);
// }

Expand Down Expand Up @@ -376,7 +376,7 @@ int PClient::handlePacket(const char* start, int bytes) {

// 为了兼容老的命令处理流程,新的命令处理流程在这里
// 后面可以把client这个类重构,完整的支持新的命令处理流程
void PClient::handlePacketNew() {
void PClient::executeCommand() {
auto [cmdPtr, ret] = g_pikiwidb->GetCmdTableManager().GetCommand(CmdName(), this);

if (!cmdPtr) {
Expand Down Expand Up @@ -520,7 +520,7 @@ bool PClient::isPeerMaster() const {
return repl_addr.GetIP() == PeerIP() && repl_addr.GetPort() == PeerPort();
}

int PClient::UniqueId() const {
int PClient::uniqueId() const {
if (auto c = getTcpConnection(); c) {
return c->GetUniqueId();
}
Expand All @@ -535,12 +535,12 @@ bool PClient::Watch(int dbno, const std::string& key) {

bool PClient::NotifyDirty(int dbno, const std::string& key) {
if (IsFlagOn(ClientFlagDirty)) {
INFO("client is already dirty {}", UniqueId());
INFO("client is already dirty {}", uniqueId());
return true;
}

if (watch_keys_[dbno].contains(key)) {
INFO("{} client become dirty because key {} in db {}", UniqueId(), key, dbno);
INFO("{} client become dirty because key {} in db {}", uniqueId(), key, dbno);
SetFlag(ClientFlagDirty);
return true;
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class CmdRes {
ret_ = kNone;
}

inline std::string Message() const { return message_; };
inline const std::string& Message() const { return message_; };

// Inline functions for Create Redis protocol
inline void AppendStringLen(int64_t ori) { RedisAppendLen(message_, ori, "$"); }
Expand Down Expand Up @@ -184,11 +184,11 @@ class PClient : public std::enable_shared_from_this<PClient>, public CmdRes {
private:
std::shared_ptr<TcpConnection> getTcpConnection() const { return tcp_connection_.lock(); }
int handlePacket(const char*, int);
void handlePacketNew();
void executeCommand();
int processInlineCmd(const char*, size_t, std::vector<std::string>&);
void reset();
bool isPeerMaster() const;
int UniqueId() const;
int uniqueId() const;

// TcpConnection's life is undetermined, so use weak ptr for safety.
std::weak_ptr<TcpConnection> tcp_connection_;
Expand Down

0 comments on commit 3b07dbe

Please sign in to comment.