Skip to content

Commit

Permalink
fix: clang warnings (dragonflydb#3509)
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Gershman <[email protected]>
Signed-off-by: Vladislav Oleshko <[email protected]>
  • Loading branch information
romange authored and dranikpg committed Aug 14, 2024
1 parent fa0913e commit ca05842
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 17 deletions.
3 changes: 2 additions & 1 deletion src/facade/reply_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ void SinkReplyBuilder2::SendError(ErrorReply error) {

void SinkReplyBuilder2::SendError(OpStatus status) {
if (status == OpStatus::OK)
return SendOk();
return SendSimpleString("OK");
// return SendOk();
SendError(StatusToMsg(status));
}

Expand Down
6 changes: 3 additions & 3 deletions src/facade/reply_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,9 @@ class SinkReplyBuilder2 {

virtual void SendStored() = 0;
virtual void SendSetSkipped() = 0;
void SendOk() {
SendSimpleString("OK");
}
// void SendOk() { // TMP
// SendSimpleString("OK");
// }

virtual void SendError(std::string_view str, std::string_view type = {}) = 0; // MC and Redis
void SendError(OpStatus status);
Expand Down
4 changes: 2 additions & 2 deletions src/facade/reply_builder_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ RedisReplyBuilderTest::ParsingResults RedisReplyBuilderTest::Parse() {

TEST_F(RedisReplyBuilderTest, MessageSend) {
// Test each message that is "sent" to the sink
builder_->SendOk();
ASSERT_EQ(TakePayload(), kOKMessage);
// builder_->SendOk();
// ASSERT_EQ(TakePayload(), kOKMessage);
builder_->StartArray(10);

std::string_view hello_msg = "hello";
Expand Down
20 changes: 11 additions & 9 deletions src/server/cluster/cluster_family.cc
Original file line number Diff line number Diff line change
Expand Up @@ -711,8 +711,8 @@ void ClusterFamily::DflySlotMigrationStatus(CmdArgList args, ConnectionContext*
vector<string> reply;
reply.reserve(incoming_migrations_jobs_.size() + outgoing_migration_jobs_.size());

auto append_answer = [rb, &reply](string_view direction, string_view node_id, string_view filter,
MigrationState state, size_t keys_number, string_view error) {
auto append_answer = [&reply](string_view direction, string_view node_id, string_view filter,
MigrationState state, size_t keys_number, string_view error) {
if (filter.empty() || filter == node_id) {
error = error.empty() ? "0" : error;
reply.push_back(absl::StrCat(direction, " ", node_id, " ", StateToStr(state),
Expand Down Expand Up @@ -794,10 +794,11 @@ SlotRanges ClusterFamily::RemoveOutgoingMigrations(shared_ptr<ClusterConfig> new
}

namespace {

// returns removed incoming migration
bool RemoveIncomingMigrationImpl(std::vector<std::shared_ptr<IncomingSlotMigration>>& jobs,
string source_id) {
auto it = std::find_if(jobs.begin(), jobs.end(), [&source_id](const auto& im) {
string_view source_id) {
auto it = std::find_if(jobs.begin(), jobs.end(), [source_id](const auto& im) {
// we can have only one migration per target-source pair
return source_id == im->GetSourceID();
});
Expand Down Expand Up @@ -840,7 +841,7 @@ void ClusterFamily::InitMigration(CmdArgList args, ConnectionContext* cntx) {
VLOG(1) << "Create incoming migration, args: " << args;
CmdArgParser parser{args};

auto [source_id, flows_num] = parser.Next<std::string, uint32_t>();
auto [source_id, flows_num] = parser.Next<string_view, uint32_t>();

std::vector<SlotRange> slots;
do {
Expand All @@ -853,7 +854,7 @@ void ClusterFamily::InitMigration(CmdArgList args, ConnectionContext* cntx) {

const auto& incoming_migrations = cluster_config()->GetIncomingMigrations();
bool found = any_of(incoming_migrations.begin(), incoming_migrations.end(),
[&](const MigrationInfo& info) {
[source_id = source_id](const MigrationInfo& info) {
// TODO: also compare slot ranges (in an order-agnostic way)
return info.node_info.id == source_id;
});
Expand All @@ -869,7 +870,7 @@ void ClusterFamily::InitMigration(CmdArgList args, ConnectionContext* cntx) {
LOG_IF(WARNING, was_removed) << "Reinit issued for migration from:" << source_id;

incoming_migrations_jobs_.emplace_back(make_shared<IncomingSlotMigration>(
std::move(source_id), &server_family_->service(), SlotRanges(std::move(slots)), flows_num));
string(source_id), &server_family_->service(), SlotRanges(std::move(slots)), flows_num));

return cntx->SendOk();
}
Expand Down Expand Up @@ -961,8 +962,9 @@ void ClusterFamily::DflyMigrateAck(CmdArgList args, ConnectionContext* cntx) {

VLOG(1) << "DFLYMIGRATE ACK" << args;
auto in_migrations = tl_cluster_config->GetIncomingMigrations();
auto m_it = std::find_if(in_migrations.begin(), in_migrations.end(),
[source_id](const auto& m) { return m.node_info.id == source_id; });
auto m_it =
std::find_if(in_migrations.begin(), in_migrations.end(),
[source_id = source_id](const auto& m) { return m.node_info.id == source_id; });
if (m_it == in_migrations.end()) {
LOG(WARNING) << "migration isn't in config";
return cntx->SendLong(OutgoingMigration::kInvalidAttempt);
Expand Down
2 changes: 1 addition & 1 deletion src/server/cluster/incoming_slot_migration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class ClusterShardMigration {
std::error_code Cancel() {
std::lock_guard lk(mu_);
if (socket_ != nullptr) {
return socket_->proactor()->Await([s = socket_, sid = source_shard_id_]() {
return socket_->proactor()->Await([s = socket_]() {
if (s->IsOpen()) {
return s->Shutdown(SHUT_RDWR); // Does not Close(), only forbids further I/O.
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/journal/streamer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ bool RestoreStreamer::ShouldWrite(const journal::JournalItem& item) const {
// On FLUSH* we restart the migration
CHECK(dest_ != nullptr);
cntx_->ReportError("FLUSH command during migration");
dest_->Shutdown(SHUT_RDWR);
std::ignore = dest_->Shutdown(SHUT_RDWR);
return false;
}

Expand Down

0 comments on commit ca05842

Please sign in to comment.