acelyc111 commented on code in PR #1061:
URL: https://github.com/apache/incubator-pegasus/pull/1061#discussion_r925257714
##########
src/rdsn/src/common/replication_common.cpp:
##########
@@ -477,7 +477,23 @@ bool replica_helper::load_meta_servers(/*out*/
std::vector<dsn::rpc_address> &se
::dsn::utils::split_args(server_list.c_str(), lv, ',');
for (auto &s : lv) {
::dsn::rpc_address addr;
- if (!addr.from_string_ipv4(s.c_str())) {
+ std::vector<std::string> hostname_port;
+ uint32_t ip = 0;
+ utils::split_args(s.c_str(), hostname_port, ':');
+ dassert(2 == hostname_port.size(),
+ "invalid address '{}' specified in config [{}].{}",
+ s.c_str(),
+ section,
+ key);
+ unsigned int port_num;
+ dassert(dsn::internal::buf2unsigned(hostname_port[1], port_num) &&
port_num < UINT16_MAX,
Review Comment:
`dassert_f`
##########
src/rdsn/src/common/replication_common.cpp:
##########
@@ -477,7 +477,23 @@ bool replica_helper::load_meta_servers(/*out*/
std::vector<dsn::rpc_address> &se
::dsn::utils::split_args(server_list.c_str(), lv, ',');
for (auto &s : lv) {
::dsn::rpc_address addr;
- if (!addr.from_string_ipv4(s.c_str())) {
+ std::vector<std::string> hostname_port;
+ uint32_t ip = 0;
+ utils::split_args(s.c_str(), hostname_port, ':');
+ dassert(2 == hostname_port.size(),
+ "invalid address '{}' specified in config [{}].{}",
+ s.c_str(),
+ section,
+ key);
+ unsigned int port_num;
+ dassert(dsn::internal::buf2unsigned(hostname_port[1], port_num) &&
port_num < UINT16_MAX,
+ "invalid address '{}' specified in config [{}].{}",
+ s.c_str(),
+ section,
+ key);
+ if (0 != (ip =
::dsn::rpc_address::ipv4_from_host(hostname_port[0].c_str()))) {
+ addr.assign_ipv4(ip, (uint16_t)port_num);
Review Comment:
use `static_cast<uint16_t>` instead
##########
src/rdsn/src/common/replication_common.cpp:
##########
@@ -477,7 +477,23 @@ bool replica_helper::load_meta_servers(/*out*/
std::vector<dsn::rpc_address> &se
::dsn::utils::split_args(server_list.c_str(), lv, ',');
for (auto &s : lv) {
::dsn::rpc_address addr;
- if (!addr.from_string_ipv4(s.c_str())) {
+ std::vector<std::string> hostname_port;
+ uint32_t ip = 0;
+ utils::split_args(s.c_str(), hostname_port, ':');
+ dassert(2 == hostname_port.size(),
+ "invalid address '{}' specified in config [{}].{}",
+ s.c_str(),
+ section,
+ key);
+ unsigned int port_num;
Review Comment:
assign a init value to avoid compile complains on some platforms.
##########
src/rdsn/src/common/replication_common.cpp:
##########
@@ -477,7 +477,23 @@ bool replica_helper::load_meta_servers(/*out*/
std::vector<dsn::rpc_address> &se
::dsn::utils::split_args(server_list.c_str(), lv, ',');
for (auto &s : lv) {
::dsn::rpc_address addr;
- if (!addr.from_string_ipv4(s.c_str())) {
+ std::vector<std::string> hostname_port;
+ uint32_t ip = 0;
+ utils::split_args(s.c_str(), hostname_port, ':');
+ dassert(2 == hostname_port.size(),
+ "invalid address '{}' specified in config [{}].{}",
+ s.c_str(),
+ section,
+ key);
+ unsigned int port_num;
Review Comment:
`uint32_t`
##########
src/rdsn/src/common/replication_common.cpp:
##########
@@ -477,7 +477,23 @@ bool replica_helper::load_meta_servers(/*out*/
std::vector<dsn::rpc_address> &se
::dsn::utils::split_args(server_list.c_str(), lv, ',');
for (auto &s : lv) {
::dsn::rpc_address addr;
- if (!addr.from_string_ipv4(s.c_str())) {
+ std::vector<std::string> hostname_port;
+ uint32_t ip = 0;
+ utils::split_args(s.c_str(), hostname_port, ':');
+ dassert(2 == hostname_port.size(),
Review Comment:
use `dassert_f` instead
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]