From 2c2cd62036cb02046a19a393d2129ea1a059bc02 Mon Sep 17 00:00:00 2001 From: M Kelly Date: Mon, 22 Jul 2024 14:06:26 -0400 Subject: [PATCH] HPCC-31990 Add timeout to DNS lookups for soapcalls using a threadpool 2 Signed-off-by: M Kelly --- system/jlib/jsocket.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/system/jlib/jsocket.cpp b/system/jlib/jsocket.cpp index b67c7ce61ac..73b585e0c03 100644 --- a/system/jlib/jsocket.cpp +++ b/system/jlib/jsocket.cpp @@ -498,13 +498,12 @@ class CAddrPoolThread : public CInterface, implements IPooledThread virtual void init(void *param) override { - localAddrThreadInfo.set((CAddrInfoThreadArgs *)param); + localAddrThreadInfo.setown((CAddrInfoThreadArgs *)param); } virtual void threadmain() override { localAddrThreadInfo->result = getAddressInfo(localAddrThreadInfo->name.get(), localAddrThreadInfo->netaddr, false); - localAddrThreadInfo->Release(); } virtual bool stop() override @@ -542,7 +541,7 @@ static bool useDNSTimeout() if (!addrInfoPool) { addrInfoFactory.setown(new CAddrInfoFactory); - addrInfoPool.setown(createThreadPool("AddrInfoPool", addrInfoFactory, false, nullptr, maxDNSThreads, 100000000)); + addrInfoPool.setown(createThreadPool("AddrInfoPool", addrInfoFactory, true, nullptr, maxDNSThreads, 100000000)); } } return true; @@ -3606,6 +3605,8 @@ static bool lookupHostAddress(const char *name, unsigned *netaddr, unsigned time return true; } } + // if join() returns false thread still running, but its detached, + // will terminate, release thread args and return to pool on its own ... StringBuffer emsg; emsg.appendf("getaddrinfo timed out (thread) (%d)", timeoutms);