mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Merge pull request #54909 from canhld94/revert-54893-revert-54819-ch_net_interfaces
Resubmit: Avoid excessive calls to getifaddrs in isLocalAddress
This commit is contained in:
commit
d29092f8af
@ -4,6 +4,7 @@
|
||||
#include <cstring>
|
||||
#include <optional>
|
||||
#include <base/types.h>
|
||||
#include <boost/core/noncopyable.hpp>
|
||||
#include <Common/Exception.h>
|
||||
#include <Common/levenshteinDistance.h>
|
||||
#include <Poco/Net/IPAddress.h>
|
||||
@ -21,7 +22,7 @@ namespace ErrorCodes
|
||||
namespace
|
||||
{
|
||||
|
||||
struct NetworkInterfaces
|
||||
struct NetworkInterfaces : public boost::noncopyable
|
||||
{
|
||||
ifaddrs * ifaddr;
|
||||
NetworkInterfaces()
|
||||
@ -112,8 +113,8 @@ bool isLocalAddress(const Poco::Net::IPAddress & address)
|
||||
}
|
||||
}
|
||||
|
||||
NetworkInterfaces interfaces;
|
||||
return interfaces.hasAddress(address);
|
||||
static NetworkInterfaces network_interfaces;
|
||||
return network_interfaces.hasAddress(address);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user