Fix build and C++ tests for FreeBSD (#10480)

This commit is contained in:
Philip Hyunsu Cho
2024-06-28 01:47:55 -07:00
committed by GitHub
parent e8a962575a
commit 09d32f1f2b
8 changed files with 79 additions and 11 deletions

View File

@@ -22,10 +22,12 @@ namespace xgboost::collective {
SockAddress MakeSockAddress(StringView host, in_port_t port) {
struct addrinfo hints;
std::memset(&hints, 0, sizeof(hints));
hints.ai_protocol = SOCK_STREAM;
hints.ai_socktype = SOCK_STREAM;
struct addrinfo *res = nullptr;
int sig = getaddrinfo(host.c_str(), nullptr, &hints, &res);
if (sig != 0) {
LOG(FATAL) << "Failed to get addr info for: " << host
<< ", error: " << gai_strerror(sig);
return {};
}
if (res->ai_family == static_cast<std::int32_t>(SockDomain::kV4)) {