Skip to content

Commit

Permalink
cr1
Browse files Browse the repository at this point in the history
  • Loading branch information
acelyc111 committed Dec 1, 2022
1 parent 5ec0877 commit 0e2e9c0
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 25 deletions.
7 changes: 3 additions & 4 deletions src/block_service/fds/fds_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

#include "block_service/fds/fds_service.h"

#include <string.h>

#include <cstring>
#include <fstream>
#include <memory>

Expand All @@ -28,14 +27,14 @@
#include <galaxy_fds_client.h>
#include <galaxy_fds_client_exception.h>
#include <model/delete_multi_objects_result.h>
#include <model/fds_object_metadata.h>
#include <model/fds_object.h>
#include <model/fds_object_metadata.h>
#include <model/fds_object_listing.h>
#include <model/fds_object_summary.h>
#include <Poco/Net/HTTPResponse.h>

#include "utils/error_code.h"
#include "utils/defer.h"
#include "utils/error_code.h"
#include "utils/filesystem.h"
#include "utils/flags.h"
#include "utils/fmt_logging.h"
Expand Down
26 changes: 14 additions & 12 deletions src/runtime/rpc/group_address.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ class rpc_group_address : public ref_counter
rpc_group_address(const char *name);
rpc_group_address(const rpc_group_address &other);
rpc_group_address &operator=(const rpc_group_address &other);
bool add(rpc_address addr); // TODO(yingchun): WARN_UNUSED_RESULT
bool add(rpc_address addr) WARN_UNUSED_RESULT;
void add_list(const std::vector<rpc_address> &addrs)
{
for (const rpc_address &addr : addrs) {
for (const auto &addr : addrs) {
// TODO(yingchun): add LOG_WARNING_IF/LOG_ERROR_IF
if (!add(addr)) {
LOG_WARNING_F("duplicate adress {}", addr);
}
}
}
void set_leader(rpc_address addr);
bool remove(rpc_address addr); // TODO(yingchun): WARN_UNUSED_RESULT
bool contains(rpc_address addr); // TODO(yingchun): WARN_UNUSED_RESULT
bool remove(rpc_address addr) WARN_UNUSED_RESULT;
bool contains(rpc_address addr) const WARN_UNUSED_RESULT;
int count();

const std::vector<rpc_address> &members() const { return _members; }
Expand Down Expand Up @@ -175,18 +175,20 @@ inline bool rpc_group_address::remove(rpc_address addr)
{
alw_t l(_lock);
auto it = std::find(_members.begin(), _members.end(), addr);
bool r = (it != _members.end());
if (r) {
if (-1 != _leader_index && addr == _members[_leader_index]) {
_leader_index = -1;
}
if (it == _members.end()) {
return false;
}

_members.erase(it);
if (-1 != _leader_index && addr == _members[_leader_index]) {
_leader_index = -1;
}
return r;

_members.erase(it);

return true;
}

inline bool rpc_group_address::contains(rpc_address addr)
inline bool rpc_group_address::contains(rpc_address addr) const
{
alr_t l(_lock);
return _members.end() != std::find(_members.begin(), _members.end(), addr);
Expand Down
3 changes: 1 addition & 2 deletions src/runtime/rpc/rpc_address.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ uint32_t rpc_address::ipv4_from_host(const char *name)
// TODO(yingchun): use getaddrinfo instead
hostent *hp = ::gethostbyname(name);
if (dsn_unlikely(hp == nullptr)) {
LOG_ERROR_F(
"gethostbyname failed, name = {}, err = {}", name, utils::safe_strerror(h_errno));
LOG_ERROR_F("gethostbyname failed, name = {}, err = {}", name, hstrerror(h_errno));
return 0;
}

Expand Down
6 changes: 3 additions & 3 deletions src/runtime/rpc/rpc_address.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class rpc_address
// and you MUST ensure that _addr is INITIALIZED before you call this function
void set_invalid();

bool operator==(rpc_address r) const
bool operator==(const rpc_address &r) const
{
if (this == &r) {
return true;
Expand All @@ -154,9 +154,9 @@ class rpc_address
}
}

bool operator!=(rpc_address r) const { return !(*this == r); }
bool operator!=(const rpc_address &r) const { return !(*this == r); }

bool operator<(rpc_address r) const
bool operator<(const rpc_address &r) const
{
if (type() != r.type())
return type() < r.type();
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/test/address_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ TEST(rpc_address_test, operators)
ASSERT_NE(addr, addr_grp);

addr_grp.assign_group("test_group");
addr_grp.group_address()->add(addr);
ASSERT_TRUE(addr_grp.group_address()->add(addr));
ASSERT_NE(addr, addr_grp);

{
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/test/rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static dsn::rpc_address build_group()
server_group.assign_group("server_group.test");
dsn::rpc_group_address *g = server_group.group_address();
for (uint16_t p = TEST_PORT_BEGIN; p <= TEST_PORT_END; ++p) {
g->add(dsn::rpc_address("localhost", p));
CHECK(g->add(dsn::rpc_address("localhost", p)), "");
}

g->set_leader(dsn::rpc_address("localhost", TEST_PORT_BEGIN));
Expand Down
2 changes: 1 addition & 1 deletion src/server/info_collector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ info_collector::info_collector()

_meta_servers.assign_group("meta-servers");
for (auto &ms : meta_servers) {
_meta_servers.group_address()->add(ms);
CHECK(_meta_servers.group_address()->add(ms), "");
}

_cluster_name = dsn::get_current_cluster_name();
Expand Down
2 changes: 1 addition & 1 deletion src/utils/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
#pragma once

#include <functional>
#include <memory>
#include <map>
#include <memory>
#include <set>

#include "runtime/rpc/rpc_address.h"
Expand Down

0 comments on commit 0e2e9c0

Please sign in to comment.