Fix --disable-tdns (thanks kerio)

This commit is contained in:
Alexey Sokolov
2015-12-06 12:36:16 +00:00
parent ec73703865
commit 582cd635f5
3 changed files with 33 additions and 28 deletions
+26 -23
View File
@@ -305,33 +305,36 @@ AC_SEARCH_LIBS([dlopen], [dl], [],
# ----- Check for pthreads
AX_PTHREAD([
AC_DEFINE([HAVE_PTHREAD], [1], [Define if you have POSIX threads libraries and header files.])
appendCXX "$PTHREAD_CFLAGS"
appendLib "$PTHREAD_LIBS"
], [
AC_MSG_ERROR([This compiler/OS doesn't seem to support pthreads.])
])
# Note that old broken systems, such as OpenBSD, NetBSD, which don't support AI_ADDRCONFIG, also have thread-unsafe getaddrinfo().
# Gladly, they fixed thread-safety before support of AI_ADDRCONFIG, so this can be abused to detect the thread-safe getaddrinfo().
#
# TODO: drop support of blocking DNS at some point. OpenBSD supports AI_ADDRCONFIG since Nov 2014, and their getaddrinfo() is thread-safe since Nov 2013. NetBSD's one is thread-safe since ages ago.
DNS_TEXT=blocking
if test "x$TDNS" != "xno"; then
old_TDNS=$TDNS
AX_PTHREAD([
AC_DEFINE([HAVE_PTHREAD], [1], [Define if you have POSIX threads libraries and header files.])
appendCXX "$PTHREAD_CFLAGS"
appendLib "$PTHREAD_LIBS"
AC_MSG_CHECKING([whether getaddrinfo() supports AI_ADDRCONFIG])
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
]], [[
int x = AI_ADDRCONFIG;
(void) x;
]])
], [
AC_MSG_RESULT([yes])
TDNS=yes
], [
AC_MSG_RESULT([no])
TDNS=no
# Note that broken systems, such as OpenBSD, NetBSD, which don't support AI_ADDRCONFIG,
# also have thread-unsafe getaddrinfo().
])
AC_MSG_CHECKING([whether getaddrinfo() supports AI_ADDRCONFIG])
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
]], [[
int x = AI_ADDRCONFIG;
(void) x;
]])
], [
AC_MSG_RESULT([yes])
TDNS=yes
], [
AC_MSG_RESULT([no])
TDNS=no
])
if test "x$TDNS" = "xyes"; then
+4 -2
View File
@@ -135,8 +135,10 @@ public:
private:
void FinishConnect(const CString& sHostname, u_short iPort, const CString& sSockName, int iTimeout, bool bSSL, const CString& sBindHost, CZNCSock *pcSock);
class CTDNSMonitorFD;
friend class CTDNSMonitorFD;
#ifdef HAVE_PTHREAD
class CThreadMonitorFD;
friend class CThreadMonitorFD;
#endif
#ifdef HAVE_THREADED_DNS
struct TDNSTask {
TDNSTask() : sHostname(""), iPort(0), sSockName(""), iTimeout(0), bSSL(false), sBindhost(""), pcSock(nullptr), bDoneTarget(false), bDoneBind(false), aiTarget(nullptr), aiBind(nullptr) {}
+3 -3
View File
@@ -158,9 +158,9 @@ CString CZNCSock::GetSSLPeerFingerprint() const {
}
#ifdef HAVE_PTHREAD
class CSockManager::CTDNSMonitorFD : public CSMonitorFD {
class CSockManager::CThreadMonitorFD : public CSMonitorFD {
public:
CTDNSMonitorFD() {
CThreadMonitorFD() {
Add(CThreadPool::Get().getReadFD(), ECT_Read);
}
@@ -346,7 +346,7 @@ void CSockManager::SetTDNSThreadFinished(TDNSTask* task, bool bBind, addrinfo* a
CSockManager::CSockManager() {
#ifdef HAVE_PTHREAD
MonitorFD(new CTDNSMonitorFD());
MonitorFD(new CThreadMonitorFD());
#endif
}