Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

Commit

Permalink
fix: fix building errors by clang-9 (#578)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wu Tao authored Aug 5, 2020
1 parent 11876e4 commit 409c846
Show file tree
Hide file tree
Showing 16 changed files with 96 additions and 67 deletions.
2 changes: 2 additions & 0 deletions include/dsn/cpp/pipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ struct do_when : when<Args...>

void run(Args &&... args) override { _cb(std::forward<Args>(args)...); }

virtual ~do_when() = default;

private:
std::function<void(Args &&...)> _cb;
};
Expand Down
2 changes: 1 addition & 1 deletion src/aio/native_linux_aio_provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ native_linux_aio_provider::native_linux_aio_provider(disk_engine *disk) : aio_pr
dassert(ret == 0, "io_setup error, ret = %d", ret);

_is_running = true;
_worker = std::thread([this, disk]() {
_worker = std::thread([this]() {
task::set_tls_dsn_context(node(), nullptr);
get_event();
});
Expand Down
5 changes: 2 additions & 3 deletions src/block_service/block_service_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ error_code block_service_manager::download_file(const std::string &remote_dir,
error_code download_err = ERR_OK;
task_tracker tracker;

auto download_file_callback_func = [this, &download_err, &download_file_size](
auto download_file_callback_func = [&download_err, &download_file_size](
const download_response &resp, block_file_ptr bf, const std::string &local_file_name) {
if (resp.err != ERR_OK) {
// during bulk load process, ERR_OBJECT_NOT_FOUND will be considered as a recoverable
Expand Down Expand Up @@ -144,8 +144,7 @@ error_code block_service_manager::download_file(const std::string &remote_dir,
download_file_size = resp.downloaded_size;
};

auto create_file_cb = [this,
&local_dir,
auto create_file_cb = [&local_dir,
&download_err,
&download_file_size,
&download_file_callback_func,
Expand Down
7 changes: 3 additions & 4 deletions src/meta/meta_bulk_load_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ namespace dsn {
namespace replication {

bulk_load_service::bulk_load_service(meta_service *meta_svc, const std::string &bulk_load_dir)
: _meta_svc(meta_svc), _bulk_load_root(bulk_load_dir)
: _meta_svc(meta_svc), _state(meta_svc->get_server_state()), _bulk_load_root(bulk_load_dir)
{
_state = _meta_svc->get_server_state();
}

// ThreadPool: THREAD_POOL_META_SERVER
Expand Down Expand Up @@ -1254,14 +1253,14 @@ void bulk_load_service::on_query_bulk_load_status(query_bulk_load_rpc rpc)
response.app_status = get_app_bulk_load_status_unlocked(app_id);

response.partitions_status.resize(partition_count);
for (const auto kv : _partition_bulk_load_info) {
for (const auto &kv : _partition_bulk_load_info) {
if (kv.first.get_app_id() == app_id) {
response.partitions_status[kv.first.get_partition_index()] = kv.second.status;
}
}

response.bulk_load_states.resize(partition_count);
for (const auto kv : _partitions_bulk_load_state) {
for (const auto &kv : _partitions_bulk_load_state) {
if (kv.first.get_app_id() == app_id) {
response.bulk_load_states[kv.first.get_partition_index()] = kv.second;
}
Expand Down
54 changes: 54 additions & 0 deletions src/meta/meta_rpc_types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

#pragma once

#include <dsn/dist/replication/replication_types.h>
#include <dsn/cpp/rpc_holder.h>

namespace dsn {
namespace replication {

typedef rpc_holder<configuration_update_app_env_request, configuration_update_app_env_response>
app_env_rpc;
typedef rpc_holder<ddd_diagnose_request, ddd_diagnose_response> ddd_diagnose_rpc;
typedef rpc_holder<app_partition_split_request, app_partition_split_response>
app_partition_split_rpc;
typedef rpc_holder<configuration_query_by_node_request, configuration_query_by_node_response>
configuration_query_by_node_rpc;
typedef rpc_holder<configuration_query_by_index_request, configuration_query_by_index_response>
configuration_query_by_index_rpc;
typedef rpc_holder<configuration_list_apps_request, configuration_list_apps_response>
configuration_list_apps_rpc;
typedef rpc_holder<configuration_list_nodes_request, configuration_list_nodes_response>
configuration_list_nodes_rpc;
typedef rpc_holder<configuration_cluster_info_request, configuration_cluster_info_response>
configuration_cluster_info_rpc;
typedef rpc_holder<configuration_balancer_request, configuration_balancer_response>
configuration_balancer_rpc;
typedef rpc_holder<configuration_meta_control_request, configuration_meta_control_response>
configuration_meta_control_rpc;
typedef rpc_holder<configuration_recovery_request, configuration_recovery_response>
configuration_recovery_rpc;
typedef rpc_holder<configuration_report_restore_status_request,
configuration_report_restore_status_response>
configuration_report_restore_status_rpc;
typedef rpc_holder<configuration_query_restore_request, configuration_query_restore_response>
configuration_query_restore_rpc;

} // namespace replication
} // namespace dsn
28 changes: 1 addition & 27 deletions src/meta/meta_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include <dsn/perf_counter/perf_counter_wrapper.h>

#include "common/replication_common.h"
#include "meta_rpc_types.h"
#include "meta_options.h"
#include "meta_backup_service.h"
#include "meta_state_service_utils.h"
Expand All @@ -62,33 +63,6 @@ class test_checker;

DEFINE_TASK_CODE(LPC_DEFAULT_CALLBACK, TASK_PRIORITY_COMMON, dsn::THREAD_POOL_DEFAULT)

typedef rpc_holder<configuration_update_app_env_request, configuration_update_app_env_response>
app_env_rpc;
typedef rpc_holder<ddd_diagnose_request, ddd_diagnose_response> ddd_diagnose_rpc;
typedef rpc_holder<app_partition_split_request, app_partition_split_response>
app_partition_split_rpc;
typedef rpc_holder<configuration_query_by_node_request, configuration_query_by_node_response>
configuration_query_by_node_rpc;
typedef rpc_holder<configuration_query_by_index_request, configuration_query_by_index_response>
configuration_query_by_index_rpc;
typedef rpc_holder<configuration_list_apps_request, configuration_list_apps_response>
configuration_list_apps_rpc;
typedef rpc_holder<configuration_list_nodes_request, configuration_list_nodes_response>
configuration_list_nodes_rpc;
typedef rpc_holder<configuration_cluster_info_request, configuration_cluster_info_response>
configuration_cluster_info_rpc;
typedef rpc_holder<configuration_balancer_request, configuration_balancer_response>
configuration_balancer_rpc;
typedef rpc_holder<configuration_meta_control_request, configuration_meta_control_response>
configuration_meta_control_rpc;
typedef rpc_holder<configuration_recovery_request, configuration_recovery_response>
configuration_recovery_rpc;
typedef rpc_holder<configuration_report_restore_status_request,
configuration_report_restore_status_response>
configuration_report_restore_status_rpc;
typedef rpc_holder<configuration_query_restore_request, configuration_query_restore_response>
configuration_query_restore_rpc;

class meta_service : public serverlet<meta_service>
{
public:
Expand Down
16 changes: 8 additions & 8 deletions src/meta/test/meta_bulk_load_service_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class bulk_load_service_test : public meta_test_base

// mock app
for (auto &info : app_list) {
mock_app_on_remote_stroage(info);
mock_app_on_remote_storage(info);
}
state->initialize_data_structure();

Expand Down Expand Up @@ -182,7 +182,7 @@ class bulk_load_service_test : public meta_test_base
auto app_iter = app_bulk_load_info_map.find(app_id);
auto partition_iter = partition_bulk_load_info_map.find(app_id);
if (app_iter != app_bulk_load_info_map.end()) {
mock_app_bulk_load_info_on_remote_stroage(
mock_app_bulk_load_info_on_remote_storage(
app_iter->second,
partition_iter == partition_bulk_load_info_map.end()
? pinfo_map
Expand All @@ -193,7 +193,7 @@ class bulk_load_service_test : public meta_test_base
wait_all();
}

void mock_app_bulk_load_info_on_remote_stroage(
void mock_app_bulk_load_info_on_remote_storage(
const app_bulk_load_info &ainfo,
const std::unordered_map<int32_t, partition_bulk_load_info> &partition_bulk_load_info_map)
{
Expand All @@ -210,27 +210,27 @@ class bulk_load_service_test : public meta_test_base
app_path,
dsn::enum_to_string(ainfo.status));
for (const auto kv : partition_bulk_load_info_map) {
mock_partition_bulk_load_info_on_remote_stroage(gpid(ainfo.app_id, kv.first),
mock_partition_bulk_load_info_on_remote_storage(gpid(ainfo.app_id, kv.first),
kv.second);
}
});
}

void mock_partition_bulk_load_info_on_remote_stroage(const gpid &pid,
void mock_partition_bulk_load_info_on_remote_storage(const gpid &pid,
const partition_bulk_load_info &pinfo)
{
std::string partition_path = bulk_svc().get_partition_bulk_load_path(pid);
blob value = json::json_forwarder<partition_bulk_load_info>::encode(pinfo);
_ms->get_meta_storage()->create_node(
std::move(partition_path), std::move(value), [this, partition_path, pid, &pinfo]() {
std::move(partition_path), std::move(value), [partition_path, pid, &pinfo]() {
ddebug_f("create partition[{}] bulk load dir({}), bulk_load_status={}",
pid,
partition_path,
dsn::enum_to_string(pinfo.status));
});
}

void mock_app_on_remote_stroage(const app_info &info)
void mock_app_on_remote_storage(const app_info &info)
{
static const char *lock_state = "lock";
static const char *unlock_state = "unlock";
Expand Down Expand Up @@ -258,7 +258,7 @@ class bulk_load_service_test : public meta_test_base
_app_root + "/" + boost::lexical_cast<std::string>(info.app_id) + "/" +
boost::lexical_cast<std::string>(i),
std::move(v),
[info, i, this]() {
[info, i]() {
ddebug_f("create app({}), partition({}.{}) dir succeed",
info.app_name,
info.app_id,
Expand Down
14 changes: 7 additions & 7 deletions src/replica/duplication/duplication_pipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ using namespace literals::chrono_literals;
// load_mutation is a pipeline stage for loading mutations, aka mutation_tuple_set,
// to the next stage, `ship_mutation`.
// ThreadPool: THREAD_POOL_REPLICATION
class load_mutation : public replica_base,
public pipeline::when<>,
public pipeline::result<decree, mutation_tuple_set>
class load_mutation final : public replica_base,
public pipeline::when<>,
public pipeline::result<decree, mutation_tuple_set>
{
public:
void run() override;
Expand All @@ -44,9 +44,9 @@ class load_mutation : public replica_base,
// sending them to the remote cluster. After finished, the pipeline
// will restart from load_mutation.
// ThreadPool: THREAD_POOL_REPLICATION
class ship_mutation : public replica_base,
public pipeline::when<decree, mutation_tuple_set>,
public pipeline::result<>
class ship_mutation final : public replica_base,
public pipeline::when<decree, mutation_tuple_set>,
public pipeline::result<>
{
public:
void run(decree &&last_decree, mutation_tuple_set &&in) override;
Expand All @@ -60,7 +60,7 @@ class ship_mutation : public replica_base,
private:
void update_progress();

friend struct ship_mutation_test;
friend class ship_mutation_test;
friend class replica_duplicator_test;

std::unique_ptr<mutation_duplicator> _mutation_duplicator;
Expand Down
6 changes: 3 additions & 3 deletions src/replica/duplication/load_from_private_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class replica_stub;
/// It works in THREAD_POOL_REPLICATION_LONG (LPC_DUPLICATION_LOAD_MUTATIONS),
/// which permits tasks to be executed in a blocking way.
/// NOTE: The resulted `mutation_tuple_set` may be empty.
class load_from_private_log : public replica_base,
public pipeline::when<>,
public pipeline::result<decree, mutation_tuple_set>
class load_from_private_log final : public replica_base,
public pipeline::when<>,
public pipeline::result<decree, mutation_tuple_set>
{
public:
load_from_private_log(replica *r, replica_duplicator *dup);
Expand Down
2 changes: 1 addition & 1 deletion src/replica/duplication/test/duplication_test_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class duplication_test_base : public replica_test_base
return log_file_map;
}

mutation_ptr create_test_mutation(int64_t decree, string_view data) override
mutation_ptr create_test_mutation(int64_t decree, const std::string &data) override
{
auto mut = replica_test_base::create_test_mutation(decree, data);
mut->data.updates[0].code = RPC_DUPLICATION_IDEMPOTENT_WRITE; // must be idempotent write
Expand Down
3 changes: 2 additions & 1 deletion src/replica/duplication/test/ship_mutation_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ struct mock_stage : pipeline::when<>
void run() override {}
};

struct ship_mutation_test : public duplication_test_base
class ship_mutation_test : public duplication_test_base
{
public:
ship_mutation_test()
{
_replica->init_private_log(_log_dir);
Expand Down
2 changes: 1 addition & 1 deletion src/replica/replica_split.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ error_code replica::child_apply_private_logs(std::vector<std::string> plog_files

// replay private log
ec = mutation_log::replay(plog_files,
[this, &plist](int log_length, mutation_ptr &mu) {
[&plist](int log_length, mutation_ptr &mu) {
decree d = mu->data.header.decree;
if (d <= plist.last_committed_decree()) {
return false;
Expand Down
4 changes: 2 additions & 2 deletions src/replica/replica_stub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ void replica_stub::initialize(const replication_options &opts, bool clear /* = f
_fs_manager.add_replica(kv.first, kv.second->dir());
}

_nfs = std::move(dsn::nfs_node::create());
_nfs = dsn::nfs_node::create();
_nfs->start();

dist::cmd::register_remote_command_rpc();
Expand Down Expand Up @@ -2732,7 +2732,7 @@ replica_stub::split_replica_exec(dsn::task_code code, gpid pid, local_execution
if (replica && handler) {
tasking::enqueue(code,
replica.get()->tracker(),
[this, handler, replica]() { handler(replica); },
[handler, replica]() { handler(replica); },
pid.thread_hash());
return ERR_OK;
}
Expand Down
14 changes: 7 additions & 7 deletions src/replica/test/mutation_log_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ TEST(replication, log_file)
lf->reset_stream();
for (int i = 0; i < 100; i++) {
blob bb;
auto err = lf->read_next_log_block(bb);
ASSERT_EQ(ERR_OK, err);
auto err2 = lf->read_next_log_block(bb);
ASSERT_EQ(ERR_OK, err2);

binary_reader reader(bb);

Expand Down Expand Up @@ -280,7 +280,7 @@ class mutation_log_test : public replica_test_base

void TearDown() override { utils::filesystem::remove_path(_log_dir); }

mutation_ptr create_test_mutation(const std::string &data, decree d)
mutation_ptr create_test_mutation(decree d, const std::string &data) override
{
mutation_ptr mu(new mutation());
mu->data.header.ballot = 1;
Expand Down Expand Up @@ -316,7 +316,7 @@ class mutation_log_test : public replica_test_base
mutation_log_ptr mlog = create_private_log();
for (int i = 1; i <= 10; i++) {
std::string msg = "hello!";
mutation_ptr mu = create_test_mutation(msg, 10 * f + i);
mutation_ptr mu = create_test_mutation(10 * f + i, msg);
mlog->append(mu, LPC_AIO_IMMEDIATE_CALLBACK, nullptr, nullptr, 0);
}
mlog->tracker()->wait_outstanding_tasks();
Expand Down Expand Up @@ -358,7 +358,7 @@ class mutation_log_test : public replica_test_base
mutation_log_ptr mlog = create_private_log();

for (int i = 0; i < num_entries; i++) {
mutation_ptr mu = create_test_mutation("hello!", 2 + i);
mutation_ptr mu = create_test_mutation(2 + i, "hello!");
mutations.push_back(mu);
mlog->append(mu, LPC_AIO_IMMEDIATE_CALLBACK, nullptr, nullptr, 0);
}
Expand Down Expand Up @@ -396,7 +396,7 @@ class mutation_log_test : public replica_test_base
{ // writing logs
mutation_log_ptr mlog = create_private_log(private_log_file_size_mb);
for (int i = 0; i < num_entries; i++) {
mutation_ptr mu = create_test_mutation("hello!", 2 + i);
mutation_ptr mu = create_test_mutation(2 + i, "hello!");
mutations.push_back(mu);
mlog->append(mu, LPC_AIO_IMMEDIATE_CALLBACK, nullptr, nullptr, 0);
}
Expand Down Expand Up @@ -450,7 +450,7 @@ TEST_F(mutation_log_test, open)
mutation_log_ptr mlog = create_private_log(4);

for (int i = 0; i < 1000; i++) {
mutation_ptr mu = create_test_mutation("hello!", 2 + i);
mutation_ptr mu = create_test_mutation(2 + i, "hello!");
mutations.push_back(mu);
mlog->append(mu, LPC_AIO_IMMEDIATE_CALLBACK, nullptr, nullptr, 0);
}
Expand Down
2 changes: 1 addition & 1 deletion src/replica/test/replica_test_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct replica_test_base : replica_stub_test_base

replica_test_base() { _replica = create_mock_replica(stub.get(), 1, 1, _log_dir.c_str()); }

virtual mutation_ptr create_test_mutation(int64_t decree, string_view data)
virtual mutation_ptr create_test_mutation(int64_t decree, const std::string &data)
{
mutation_ptr mu(new mutation());
mu->data.header.ballot = 1;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/test/autoref_ptr_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ TEST(RefCountedUnitTest, TestSelfAssignment)
{
SelfAssign *p = new SelfAssign;
dsn::ref_ptr<SelfAssign> var(p);
var = var;
// var = var;
EXPECT_EQ(var.get(), p);
// comment the following two lines because clang compiler would complain with "-Wself-move"
// var = std::move(var);
Expand Down

0 comments on commit 409c846

Please sign in to comment.