Skip to content

Commit ecbc08a

Browse files
committed
Optimize code
1 parent f819fa8 commit ecbc08a

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

core-tests/src/coroutine/system.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ static void test_getaddrinfo(
122122
ASSERT_GT(ip_list.size(), 0);
123123
for (auto &ip : ip_list) {
124124
ASSERT_TRUE(swoole::network::Address::verify_ip(family, ip));
125+
network::Client c(family == AF_INET ? SW_SOCK_TCP : SW_SOCK_TCP6, false);
126+
ASSERT_EQ(c.connect(ip.c_str(), 443), SW_OK);
125127
}
126128
}
127129

ext-src/swoole_stdext.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "php_swoole_stdext.h"
2020
#include "php_swoole_cxx.h"
2121
#include "php_variables.h"
22-
#include "nlohmann/detail/value_t.hpp"
2322

2423
SW_EXTERN_C_BEGIN
2524
#include "ext/pcre/php_pcre.h"

src/network/dns.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,12 @@ int gethostbyname(GethostbynameRequest *req) {
832832

833833
void GetaddrinfoRequest::parse_result(std::vector<std::string> &retval) const {
834834
for (auto &addr : results) {
835-
auto addr_str = network::Address::addr_str(family, &addr);
835+
const char *addr_str;
836+
if (family == AF_INET6) {
837+
addr_str = network::Address::addr_str(family, &addr.sin6_addr);
838+
} else {
839+
addr_str = network::Address::addr_str(family, &((sockaddr_in *) &addr)->sin_addr);
840+
}
836841
if (addr_str) {
837842
retval.emplace_back(addr_str);
838843
}

0 commit comments

Comments
 (0)