[
https://issues.apache.org/jira/browse/GEODE-9327?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17494279#comment-17494279
]
ASF GitHub Bot commented on GEODE-9327:
---------------------------------------
pdxcodemonkey commented on a change in pull request #815:
URL: https://github.com/apache/geode-native/pull/815#discussion_r809521456
##########
File path: cppcache/src/ClientProxyMembershipID.cpp
##########
@@ -77,21 +77,13 @@ ClientProxyMembershipID::ClientProxyMembershipID(
}
void ClientProxyMembershipID::initHostAddressVector(
- const ACE_INET_Addr& address) {
- if (address.get_type() == AF_INET6) {
- const auto socketAddress6 =
- static_cast<const struct sockaddr_in6*>(address.get_addr());
- auto socketAddress =
- reinterpret_cast<const uint8_t*>(&socketAddress6->sin6_addr);
- auto length = sizeof(socketAddress6->sin6_addr);
- m_hostAddr.assign(socketAddress, socketAddress + length);
+ const boost::asio::ip::address& address) {
+ if (address.is_v6()) {
+ auto bytes = address.to_v6().to_bytes();
+ m_hostAddr.assign(bytes.begin(), bytes.end());
Review comment:
This is probably as good a time as any to rename member variables...
##########
File path: cppcache/src/Utils.cpp
##########
@@ -81,43 +83,36 @@ void Utils::parseEndpointString(const char* endpoints,
std::string& host,
port = atoi(endpointsStr.c_str());
}
-std::string Utils::convertHostToCanonicalForm(const char* endpoints) {
- if (endpoints == nullptr) return nullptr;
- std::string hostString("");
- uint16_t port = 0;
- std::string endpointsStr(endpoints);
- std::string endpointsStr1(endpoints);
- // Parse this string to get all hostnames and port numbers.
- std::string endpoint;
- std::string::size_type length = endpointsStr.size();
- std::string::size_type pos = 0;
- ACE_TCHAR hostName[256];
- pos = endpointsStr.find(':', 0);
- if (pos != std::string::npos) {
- endpoint = endpointsStr.substr(0, pos);
- pos += 1; // skip ':'
- length -= (pos);
- endpointsStr = endpointsStr.substr(pos, length);
- } else {
- hostString = "";
- return "";
+std::string Utils::convertHostToCanonicalForm(const std::string& endpoints) {
+ using boost::asio::io_service;
+ using boost::asio::ip::tcp;
+
+ if (endpoints.empty()) {
+ return {};
}
- hostString = endpoint;
- port = std::stoi(endpointsStr);
- if (hostString == "localhost") {
- auto hostname = boost::asio::ip::host_name();
- if (auto host = ::gethostbyname(hostname.c_str())) {
- return std::string{host->h_name} + ':' + std::to_string(port);
- }
- } else {
- pos = endpointsStr1.find('.', 0);
- if (pos != std::string::npos) {
- ACE_INET_Addr addr(endpoints);
- addr.get_host_name(hostName, 256);
- return std::string(hostName) + ":" + std::to_string(port);
- }
+
+ auto pos = endpoints.rfind(':');
+ if (pos == std::string::npos) {
+ return {};
}
- return endpoints;
+
+ auto hostname = endpoints.substr(0, pos);
+ auto port = endpoints.substr(pos);
+
+ if (hostname == "localhost") {
+ hostname = boost::asio::ip::host_name();
+ }
+
+ io_service svc;
+ boost::system::error_code ec;
+ tcp::resolver resolver{svc};
+ auto results = resolver.resolve(hostname, ec);
+
+ if (!ec) {
+ hostname = results->host_name();
+ }
+
+ return hostname + port;
Review comment:
Shouldn't this be `hostname + ":" + port`?
--
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]
> Remove all remaining references to ACE networking
> -------------------------------------------------
>
> Key: GEODE-9327
> URL: https://issues.apache.org/jira/browse/GEODE-9327
> Project: Geode
> Issue Type: Improvement
> Components: native client
> Reporter: Mario Salazar de Torres
> Assignee: Mario Salazar de Torres
> Priority: Major
> Labels: obliterate-ace, pull-request-available
>
> *AS A* native client contributor
> *I WANT TO* remove all remaining references to ACE networking
> *SO THAT* eventually we can get rid of ACE library
>
--
This message was sent by Atlassian Jira
(v8.20.1#820001)