Skip to content

Commit 10ae7a7

Browse files
committed
Revert "Use async name resolving to improve net thread responsiveness"
This reverts commit caf6150. getaddrinfo_a has a nasty tendency to segfault internally in its background thread, on every version of glibc I tested, especially under helgrind. See https://sourceware.org/bugzilla/show_bug.cgi?id=20874
1 parent ad826b3 commit 10ae7a7

File tree

2 files changed

+1
-49
lines changed

2 files changed

+1
-49
lines changed

configure.ac

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,6 @@ if test x$TARGET_OS = xdarwin; then
512512
fi
513513

514514
AC_CHECK_HEADERS([endian.h sys/endian.h byteswap.h stdio.h stdlib.h unistd.h strings.h sys/types.h sys/stat.h sys/select.h sys/prctl.h])
515-
AC_SEARCH_LIBS([getaddrinfo_a], [anl], [AC_DEFINE(HAVE_GETADDRINFO_A, 1, [Define this symbol if you have getaddrinfo_a])])
516-
AC_SEARCH_LIBS([inet_pton], [nsl resolv], [AC_DEFINE(HAVE_INET_PTON, 1, [Define this symbol if you have inet_pton])])
517515

518516
AC_CHECK_DECLS([strnlen])
519517

src/netbase.cpp

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -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.push_back(CNetAddr(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.push_back(CNetAddr(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.push_back(CNetAddr(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 reasonable 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

Comments
 (0)