MCPcopy Create free account
hub / github.com/catboost/catboost / InitLocalIPList

Function InitLocalIPList

library/cpp/netliba/v6/udp_socket.cpp:59–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57 }
58
59 bool InitLocalIPList() {
60 // Do not use TMutex here: it has a non-trivial destructor which will be called before
61 // destruction of current thread, if its TThread declared as global/static variable.
62 static TAdaptiveLock cs;
63 TGuard lock(cs);
64
65 if (LocalHostFound)
66 return true;
67
68 TVector<TUdpAddress> addrs;
69 if (!GetLocalAddresses(&addrs))
70 return false;
71 for (int i = 0; i < addrs.ysize(); ++i) {
72 const TUdpAddress& addr = addrs[i];
73 if (addr.IsIPv4()) {
74 LocalHostIPList[IPv4].push_back(addr.GetIPv4());
75 LocalHostIP[IPv4] = addr.GetIPv4();
76 } else {
77 sockaddr_in6 addr6;
78 GetWinsockAddr(&addr6, addr);
79
80 LocalHostIPList[IPv6].push_back(GetIPv6SuffixCrc(addr6));
81 LocalHostIP[IPv6] = GetIPv6SuffixCrc(addr6);
82 LocalHostIPv6List.push_back(TIPv6Addr(addr.Network, addr.Interface));
83 }
84 }
85 LocalHostFound = true;
86 return true;
87 }
88
89 template <class T, class TElem>
90 inline bool IsInSet(const T& c, const TElem& e) {

Callers 3

CreateUdpHostFunction · 0.85
InitMethod · 0.85
IsLocalFunction · 0.85

Calls 8

GetLocalAddressesFunction · 0.70
GetWinsockAddrFunction · 0.70
GetIPv6SuffixCrcFunction · 0.70
TIPv6AddrClass · 0.70
ysizeMethod · 0.45
IsIPv4Method · 0.45
push_backMethod · 0.45
GetIPv4Method · 0.45

Tested by 1

InitMethod · 0.68