Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ehds committed Apr 29, 2024
1 parent efbd0fd commit 8d03fc9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
2 changes: 0 additions & 2 deletions src/braft/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,13 @@ struct PeerId {
// |- ip:port
// |- [ipv6]:port
// |- unix:path/to/sock

// clang-format off
std::regex peerid_reg("((([^:]+)|(\\[.*\\])):[^:]+)(:(\\d)?)?(:(\\d+)?)?");
// ^ ^ ^ ^
// | | | |
// unix,host,ipv4 | idx(6)(opt) |
// ipv6 role(8)(opt)
// clang-format on

std::cmatch m;
auto ret = std::regex_match(str.c_str(), m, peerid_reg);
if (!ret || m.size() != 9) {
Expand Down
1 change: 1 addition & 0 deletions test/test_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <sys/types.h>

#include <algorithm>
#include <string>
#include <vector>

#include "../test/util.h"
Expand Down
18 changes: 12 additions & 6 deletions test/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
#define PUBLIC_RAFT_TEST_UTIL_H

#include <gflags/gflags.h>
#include <algorithm>

#include "_deps/brpc/src/src/butil/endpoint.h"
#include "brpc/server.h"
#include "butil/time.h"
#include "braft/enum.pb.h"
#include "braft/errno.pb.h"
Expand Down Expand Up @@ -278,12 +281,15 @@ class Cluster {
}
options.fsm = fsm;
options.node_owns_fsm = true;
std::string endpoint_str = butil::endpoint2str(listen_addr).c_str();
butil::string_printf(&options.log_uri, "local://./data/%s/log",
butil::endpoint2str(listen_addr).c_str());
butil::string_printf(&options.raft_meta_uri, "local://./data/%s/raft_meta",
butil::endpoint2str(listen_addr).c_str());
butil::string_printf(&options.snapshot_uri, "local://./data/%s/snapshot",
butil::endpoint2str(listen_addr).c_str());
endpoint_str.c_str());
butil::string_printf(&options.raft_meta_uri,
"local://./data/%s/raft_meta",
endpoint_str.c_str());
butil::string_printf(&options.snapshot_uri,
"local://./data/%s/snapshot",
endpoint_str.c_str());

options.snapshot_throttle = &_throttle;

Expand Down Expand Up @@ -523,7 +529,7 @@ class Cluster {
braft::Node* node = NULL;
std::vector<braft::Node*> new_nodes;
for (size_t i = 0; i < _nodes.size(); i++) {
if (addr.port == _nodes[i]->node_id().peer_id.addr.port) {
if (addr == _nodes[i]->node_id().peer_id.addr) {
node = _nodes[i];
} else {
new_nodes.push_back(_nodes[i]);
Expand Down

0 comments on commit 8d03fc9

Please sign in to comment.