Skip to content

Commit

Permalink
chore: comments
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Gershman <[email protected]>
  • Loading branch information
romange committed Jun 25, 2024
1 parent 6b0a8de commit 3e65d44
Show file tree
Hide file tree
Showing 14 changed files with 73 additions and 73 deletions.
2 changes: 1 addition & 1 deletion src/facade/ok_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class OkService : public ServiceInterface {

void DispatchMC(const MemcacheParser::Command& cmd, std::string_view value,
ConnectionContext* cntx) final {
cntx->reply_builder()->SendError("");
cntx->SendError("");
}

ConnectionContext* CreateContext(util::FiberSocketBase* peer, Connection* owner) final {
Expand Down
6 changes: 3 additions & 3 deletions src/server/cluster/cluster_family.cc
Original file line number Diff line number Diff line change
Expand Up @@ -585,12 +585,12 @@ void ClusterFamily::DflyClusterGetSlotInfo(CmdArgList args, ConnectionContext* c
do {
auto sid = parser.Next<uint32_t>();
if (sid > kMaxSlotNum)
return rb->SendError("Invalid slot id");
return cntx->SendError("Invalid slot id");
slots_stats.emplace_back(sid, SlotStats{});
} while (parser.HasNext());

if (auto err = parser.Error(); err)
return rb->SendError(err->MakeReply());
return cntx->SendError(err->MakeReply());

fb2::Mutex mu;

Expand Down Expand Up @@ -675,7 +675,7 @@ void ClusterFamily::DflySlotMigrationStatus(CmdArgList args, ConnectionContext*
if (parser.HasNext()) {
node_id = parser.Next<std::string_view>();
if (auto err = parser.Error(); err) {
return rb->SendError(err->MakeReply());
return cntx->SendError(err->MakeReply());
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/server/debugcmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -520,10 +520,10 @@ void DebugCmd::Replica(CmdArgList args) {
}
return;
} else {
return rb->SendError("I am master");
return cntx_->SendError("I am master");
}
}
return rb->SendError(UnknownSubCmd("replica", "DEBUG"));
return cntx_->SendError(UnknownSubCmd("replica", "DEBUG"));
}

void DebugCmd::Load(string_view filename) {
Expand Down
22 changes: 11 additions & 11 deletions src/server/dflycmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,15 @@ void DflyCmd::Thread(CmdArgList args, ConnectionContext* cntx) {
string_view arg = ArgS(args, 1);
unsigned num_thread;
if (!absl::SimpleAtoi(arg, &num_thread)) {
return rb->SendError(kSyntaxErr);
return cntx->SendError(kSyntaxErr);
}

if (num_thread < pool->size()) {
if (int(num_thread) != ProactorBase::me()->GetPoolIndex()) {
if (!cntx->conn()->Migrate(pool->at(num_thread))) {
// Listener::PreShutdown() triggered
if (cntx->conn()->socket()->IsOpen()) {
return rb->SendError(kInvalidState);
return cntx->SendError(kInvalidState);
}
return;
}
Expand All @@ -201,7 +201,7 @@ void DflyCmd::Thread(CmdArgList args, ConnectionContext* cntx) {
return rb->SendOk();
}

return rb->SendError(kInvalidIntErr);
return cntx->SendError(kInvalidIntErr);
}

void DflyCmd::Flow(CmdArgList args, ConnectionContext* cntx) {
Expand All @@ -214,20 +214,20 @@ void DflyCmd::Flow(CmdArgList args, ConnectionContext* cntx) {
if (args.size() == 5) {
seqid.emplace();
if (!absl::SimpleAtoi(ArgS(args, 4), &seqid.value())) {
return rb->SendError(facade::kInvalidIntErr);
return cntx->SendError(facade::kInvalidIntErr);
}
}

VLOG(1) << "Got DFLY FLOW master_id: " << master_id << " sync_id: " << sync_id_str
<< " flow: " << flow_id_str << " seq: " << seqid.value_or(-1);

if (master_id != sf_->master_replid()) {
return rb->SendError(kBadMasterId);
return cntx->SendError(kBadMasterId);
}

unsigned flow_id;
if (!absl::SimpleAtoi(flow_id_str, &flow_id) || flow_id >= shard_set->size()) {
return rb->SendError(facade::kInvalidIntErr);
return cntx->SendError(facade::kInvalidIntErr);
}

auto [sync_id, replica_ptr] = GetReplicaInfoOrReply(sync_id_str, rb);
Expand All @@ -236,7 +236,7 @@ void DflyCmd::Flow(CmdArgList args, ConnectionContext* cntx) {

unique_lock lk(replica_ptr->mu);
if (replica_ptr->replica_state != SyncState::PREPARATION)
return rb->SendError(kInvalidState);
return cntx->SendError(kInvalidState);

// Set meta info on connection.
cntx->conn()->SetName(absl::StrCat("repl_flow_", sync_id));
Expand All @@ -254,7 +254,7 @@ void DflyCmd::Flow(CmdArgList args, ConnectionContext* cntx) {
if (!cntx->conn()->Migrate(shard_set->pool()->at(flow_id))) {
// Listener::PreShutdown() triggered
if (cntx->conn()->socket()->IsOpen()) {
return rb->SendError(kInvalidState);
return cntx->SendError(kInvalidState);
}
return;
}
Expand Down Expand Up @@ -311,7 +311,7 @@ void DflyCmd::Sync(CmdArgList args, ConnectionContext* cntx) {

// TODO: Send better error
if (*status != OpStatus::OK)
return rb->SendError(kInvalidState);
return cntx->SendError(kInvalidState);
}

LOG(INFO) << "Started sync with replica " << replica_ptr->address << ":"
Expand Down Expand Up @@ -349,7 +349,7 @@ void DflyCmd::StartStable(CmdArgList args, ConnectionContext* cntx) {
shard_set->RunBlockingInParallel(std::move(cb));

if (*status != OpStatus::OK)
return rb->SendError(kInvalidState);
return cntx->SendError(kInvalidState);
}

LOG(INFO) << "Transitioned into stable sync with replica " << replica_ptr->address << ":"
Expand Down Expand Up @@ -436,7 +436,7 @@ void DflyCmd::TakeOver(CmdArgList args, ConnectionContext* cntx) {

if (*status != OpStatus::OK) {
sf_->service().SwitchState(GlobalState::TAKEN_OVER, GlobalState::ACTIVE);
return rb->SendError("Takeover failed!");
return cntx->SendError("Takeover failed!");
}
cntx->SendOk();

Expand Down
10 changes: 5 additions & 5 deletions src/server/hset_family.cc
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ void HGetGeneric(CmdArgList args, ConnectionContext* cntx, uint8_t getall_mask)
rb->SendStringArr(absl::Span<const string>{*result},
is_map ? RedisReplyBuilder::MAP : RedisReplyBuilder::ARRAY);
} else {
rb->SendError(result.status());
cntx->SendError(result.status());
}
}

Expand Down Expand Up @@ -822,7 +822,7 @@ void HSetFamily::HMGet(CmdArgList args, ConnectionContext* cntx) {
rb->SendNull();
}
} else {
rb->SendError(result.status());
cntx->SendError(result.status());
}
}

Expand All @@ -842,7 +842,7 @@ void HSetFamily::HGet(CmdArgList args, ConnectionContext* cntx) {
if (result.status() == OpStatus::KEY_NOTFOUND) {
rb->SendNull();
} else {
rb->SendError(result.status());
cntx->SendError(result.status());
}
}
}
Expand Down Expand Up @@ -965,7 +965,7 @@ void HSetFamily::HScan(CmdArgList args, ConnectionContext* cntx) {
rb->SendBulkString(k);
}
} else {
rb->SendError(result.status());
cntx->SendError(result.status());
}
}

Expand Down Expand Up @@ -1149,7 +1149,7 @@ void HSetFamily::HRandField(CmdArgList args, ConnectionContext* cntx) {
else
rb->SendEmptyArray();
} else {
rb->SendError(result.status());
cntx->SendError(result.status());
}
}

Expand Down
16 changes: 8 additions & 8 deletions src/server/json_family.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1439,7 +1439,7 @@ void JsonFamily::Set(CmdArgList args, ConnectionContext* cntx) {
rb->SendNull();
}
} else {
rb->SendError(result.status());
cntx->SendError(result.status());
}
}

Expand Down Expand Up @@ -1510,7 +1510,7 @@ void JsonFamily::Resp(CmdArgList args, ConnectionContext* cntx) {
SendJsonValue(rb, it);
}
} else {
rb->SendError(result.status());
cntx->SendError(result.status());
}
}

Expand Down Expand Up @@ -1793,7 +1793,7 @@ void JsonFamily::ArrPop(CmdArgList args, ConnectionContext* cntx) {
}
}
} else {
rb->SendError(result.status());
cntx->SendError(result.status());
}
}

Expand Down Expand Up @@ -1865,7 +1865,7 @@ void JsonFamily::ObjKeys(CmdArgList args, ConnectionContext* cntx) {
}
}
} else {
rb->SendError(result.status());
cntx->SendError(result.status());
}
}

Expand Down Expand Up @@ -1916,7 +1916,7 @@ void JsonFamily::NumIncrBy(CmdArgList args, ConnectionContext* cntx) {
if (result) {
rb->SendBulkString(*result);
} else {
rb->SendError(result.status());
cntx->SendError(result.status());
}
}

Expand Down Expand Up @@ -1944,7 +1944,7 @@ void JsonFamily::NumMultBy(CmdArgList args, ConnectionContext* cntx) {
if (result) {
rb->SendBulkString(*result);
} else {
rb->SendError(result.status());
cntx->SendError(result.status());
}
}

Expand Down Expand Up @@ -1992,7 +1992,7 @@ void JsonFamily::Type(CmdArgList args, ConnectionContext* cntx) {
if (result.status() == OpStatus::KEY_NOTFOUND) {
rb->SendNullArray();
} else {
rb->SendError(result.status());
cntx->SendError(result.status());
}
}
}
Expand Down Expand Up @@ -2112,7 +2112,7 @@ void JsonFamily::Get(CmdArgList args, ConnectionContext* cntx) {
if (result == facade::OpStatus::KEY_NOTFOUND) {
rb->SendNull(); // Match Redis
} else {
rb->SendError(result.status());
cntx->SendError(result.status());
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/server/list_family.cc
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ void MoveGeneric(ConnectionContext* cntx, string_view src, string_view dest, Lis
break;

default:
rb->SendError(result.status());
cntx->SendError(result.status());
break;
}
}
Expand Down Expand Up @@ -776,7 +776,7 @@ void BRPopLPush(CmdArgList args, ConnectionContext* cntx) {
break;

default:
return rb->SendError(op_res.status());
return cntx->SendError(op_res.status());
break;
}
}
Expand Down Expand Up @@ -819,7 +819,7 @@ void BLMove(CmdArgList args, ConnectionContext* cntx) {
break;

default:
return rb->SendError(op_res.status());
return cntx->SendError(op_res.status());
break;
}
}
Expand Down Expand Up @@ -1034,7 +1034,7 @@ void ListFamily::LIndex(CmdArgList args, ConnectionContext* cntx) {
if (result) {
rb->SendBulkString(result.value());
} else if (result.status() == OpStatus::WRONG_TYPE) {
rb->SendError(result.status());
cntx->SendError(result.status());
} else {
rb->SendNull();
}
Expand Down Expand Up @@ -1217,13 +1217,13 @@ void ListFamily::BPopGeneric(ListDir dir, CmdArgList args, ConnectionContext* cn

switch (popped_key.status()) {
case OpStatus::WRONG_TYPE:
return rb->SendError(kWrongTypeErr);
return cntx->SendError(kWrongTypeErr);
case OpStatus::CANCELLED:
case OpStatus::TIMED_OUT:
return rb->SendNullArray();
case OpStatus::KEY_MOVED:
// TODO: proper error for moved
return rb->SendError("-MOVED");
return cntx->SendError("-MOVED");
default:
LOG(ERROR) << "Unexpected error " << popped_key.status();
}
Expand Down Expand Up @@ -1277,7 +1277,7 @@ void ListFamily::PopGeneric(ListDir dir, CmdArgList args, ConnectionContext* cnt
case OpStatus::KEY_NOTFOUND:
return rb->SendNull();
case OpStatus::WRONG_TYPE:
return rb->SendError(kWrongTypeErr);
return cntx->SendError(kWrongTypeErr);
default:;
}

Expand Down
12 changes: 6 additions & 6 deletions src/server/main_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1226,7 +1226,7 @@ void Service::DispatchCommand(CmdArgList args, facade::ConnectionContext* cntx)
dfly_cntx->cid = cid;

if (!InvokeCmd(cid, args_no_cmd, dfly_cntx)) {
dfly_cntx->reply_builder()->SendError("Internal Error");
dfly_cntx->SendError("Internal Error");
dfly_cntx->reply_builder()->CloseConnection();
}

Expand Down Expand Up @@ -1756,7 +1756,7 @@ void Service::Eval(CmdArgList args, ConnectionContext* cntx) {
BorrowedInterpreter interpreter{cntx};
auto res = server_family_.script_mgr()->Insert(body, interpreter);
if (!res)
return rb->SendError(res.error().Format(), facade::kScriptErrType);
return cntx->SendError(res.error().Format(), facade::kScriptErrType);

string sha{std::move(res.value())};

Expand Down Expand Up @@ -2035,7 +2035,7 @@ void Service::Discard(CmdArgList args, ConnectionContext* cntx) {
auto* rb = static_cast<RedisReplyBuilder*>(cntx->reply_builder());

if (!cntx->conn_state.exec_info.IsCollecting()) {
return rb->SendError("DISCARD without MULTI");
return cntx->SendError("DISCARD without MULTI");
}

MultiCleanup(cntx);
Expand Down Expand Up @@ -2146,15 +2146,15 @@ void Service::Exec(CmdArgList args, ConnectionContext* cntx) {

// Check basic invariants
if (!exec_info.IsCollecting()) {
return rb->SendError("EXEC without MULTI");
return cntx->SendError("EXEC without MULTI");
}

if (IsWatchingOtherDbs(cntx->db_index(), exec_info)) {
return rb->SendError("Dragonfly does not allow WATCH and EXEC on different databases");
return cntx->SendError("Dragonfly does not allow WATCH and EXEC on different databases");
}

if (exec_info.state == ConnectionState::ExecInfo::EXEC_ERROR) {
return rb->SendError("-EXECABORT Transaction discarded because of previous errors");
return cntx->SendError("-EXECABORT Transaction discarded because of previous errors");
}

if (exec_info.watched_dirty.load(memory_order_relaxed)) {
Expand Down
2 changes: 1 addition & 1 deletion src/server/script_mgr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void ScriptMgr::LoadCmd(CmdArgList args, ConnectionContext* cntx) {

auto res = Insert(body, interpreter);
if (!res)
return rb->SendError(res.error().Format());
return cntx->SendError(res.error().Format());

// Schedule empty callback inorder to journal command via transaction framework.
cntx->transaction->ScheduleSingleHop([](auto* t, auto* shard) { return OpStatus::OK; });
Expand Down
2 changes: 1 addition & 1 deletion src/server/server_family.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1407,7 +1407,7 @@ void ServerFamily::OnClose(ConnectionContext* cntx) {

void ServerFamily::StatsMC(std::string_view section, facade::ConnectionContext* cntx) {
if (!section.empty()) {
return cntx->reply_builder()->SendError("");
return cntx->SendError("");
}
string info;

Expand Down
Loading

0 comments on commit 3e65d44

Please sign in to comment.