diff --git a/.builds/freebsd.yml b/.builds/freebsd.yml index 1f603497..3c21f1ce 100644 --- a/.builds/freebsd.yml +++ b/.builds/freebsd.yml @@ -11,7 +11,7 @@ packages: - py311-sphinx - py311-m2r - rsync - - tbb + - onetbb sources: - https://github.com/awesomized/libmemcached secrets: diff --git a/test/lib/Connection.cpp b/test/lib/Connection.cpp index d2aff8c8..5c594c1a 100644 --- a/test/lib/Connection.cpp +++ b/test/lib/Connection.cpp @@ -49,17 +49,29 @@ Connection::Connection(socket_or_port_t socket_or_port) { size = UNIX; } else { + const auto port = get(socket_or_port); + + bool useIPv6 = true; if (0 > (sock = socket_ex(AF_INET6, SOCK_STREAM, 0, SOCK_NONBLOCK|SOCK_CLOEXEC))) { - throw runtime_error(error({"socket(): ", strerror(errno)})); + useIPv6 = false; + if (0 > (sock = socket_ex(AF_INET, SOCK_STREAM, 0, SOCK_NONBLOCK|SOCK_CLOEXEC))) { + throw runtime_error(error({"socket(): ", strerror(errno)})); + } } - const auto port = get(socket_or_port); - auto sa = reinterpret_cast(&addr); - sa->sin6_family = AF_INET6; - sa->sin6_port = htons(static_cast(port)); - sa->sin6_addr = IN6ADDR_LOOPBACK_INIT; - - size = INET6; + if (useIPv6) { + auto sa = reinterpret_cast(&addr); + sa->sin6_family = AF_INET6; + sa->sin6_port = htons(static_cast(port)); + sa->sin6_addr = IN6ADDR_LOOPBACK_INIT; + size = INET6; + } else { + auto sa = reinterpret_cast(&addr); + sa->sin_family = AF_INET; + sa->sin_port = htons(static_cast(port)); + sa->sin_addr.s_addr = htonl(INADDR_LOOPBACK); + size = INET; + } } }