@@ -94,30 +94,9 @@ bool static LookupIntern(const char* pszName, std::vector<CNetAddr>& vIP, unsign
9494 }
9595 }
9696
97- #ifdef HAVE_GETADDRINFO_A
98- struct in_addr ipv4_addr;
99- #ifdef HAVE_INET_PTON
100- if (inet_pton (AF_INET, pszName, &ipv4_addr) > 0 ) {
101- vIP.emplace_back (ipv4_addr);
102- return true ;
103- }
104-
105- struct in6_addr ipv6_addr;
106- if (inet_pton (AF_INET6, pszName, &ipv6_addr) > 0 ) {
107- vIP.emplace_back (ipv6_addr);
108- return true ;
109- }
110- #else
111- ipv4_addr.s_addr = inet_addr (pszName);
112- if (ipv4_addr.s_addr != INADDR_NONE) {
113- vIP.emplace_back (ipv4_addr);
114- return true ;
115- }
116- #endif
117- #endif
118-
11997 struct addrinfo aiHint;
12098 memset (&aiHint, 0 , sizeof (struct addrinfo ));
99+
121100 aiHint.ai_socktype = SOCK_STREAM;
122101 aiHint.ai_protocol = IPPROTO_TCP;
123102 aiHint.ai_family = AF_UNSPEC;
@@ -126,33 +105,8 @@ bool static LookupIntern(const char* pszName, std::vector<CNetAddr>& vIP, unsign
126105#else
127106 aiHint.ai_flags = fAllowLookup ? AI_ADDRCONFIG : AI_NUMERICHOST;
128107#endif
129-
130108 struct addrinfo * aiRes = NULL ;
131- #ifdef HAVE_GETADDRINFO_A
132- struct gaicb gcb, *query = &gcb;
133- memset (query, 0 , sizeof (struct gaicb ));
134- gcb.ar_name = pszName;
135- gcb.ar_request = &aiHint;
136- int nErr = getaddrinfo_a (GAI_NOWAIT, &query, 1 , NULL );
137- if (nErr)
138- return false ;
139-
140- do {
141- // Should set the timeout limit to a resonable value to avoid
142- // generating unnecessary checking call during the polling loop,
143- // while it can still response to stop request quick enough.
144- // 2 seconds looks fine in our situation.
145- struct timespec ts = {2 , 0 };
146- gai_suspend (&query, 1 , &ts);
147- boost::this_thread::interruption_point ();
148-
149- nErr = gai_error (query);
150- if (0 == nErr)
151- aiRes = query->ar_result ;
152- } while (nErr == EAI_INPROGRESS);
153- #else
154109 int nErr = getaddrinfo (pszName, NULL , &aiHint, &aiRes);
155- #endif
156110 if (nErr)
157111 return false ;
158112
0 commit comments