diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:17 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:17 +0300 |
commit | d3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch) | |
tree | dd4bd3ca0f36b817e96812825ffaf10d645803f2 /library/cpp/actors/dnscachelib | |
parent | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff) | |
download | ydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/actors/dnscachelib')
-rw-r--r-- | library/cpp/actors/dnscachelib/dnscache.cpp | 130 | ||||
-rw-r--r-- | library/cpp/actors/dnscachelib/dnscache.h | 58 | ||||
-rw-r--r-- | library/cpp/actors/dnscachelib/probes.h | 56 | ||||
-rw-r--r-- | library/cpp/actors/dnscachelib/timekeeper.h | 10 |
4 files changed, 127 insertions, 127 deletions
diff --git a/library/cpp/actors/dnscachelib/dnscache.cpp b/library/cpp/actors/dnscachelib/dnscache.cpp index 31eb8468eb..649339ddb2 100644 --- a/library/cpp/actors/dnscachelib/dnscache.cpp +++ b/library/cpp/actors/dnscachelib/dnscache.cpp @@ -6,22 +6,22 @@ #include <util/system/guard.h> #include <util/datetime/systime.h> -const TDnsCache::THost TDnsCache::NullHost; +const TDnsCache::THost TDnsCache::NullHost; LWTRACE_USING(DNSCACHELIB_PROVIDER); -static_assert(sizeof(ares_channel) == sizeof(void*), "expect sizeof(ares_channel) == sizeof(void *)"); +static_assert(sizeof(ares_channel) == sizeof(void*), "expect sizeof(ares_channel) == sizeof(void *)"); TDnsCache::TDnsCache(bool allowIpv4, bool allowIpv6, time_t lifetime, time_t neg, ui32 timeout) - : EntryLifetime(lifetime) - , NegativeLifetime(neg) - , Timeout(TDuration::MicroSeconds(timeout)) - , AllowIpV4(allowIpv4) - , AllowIpV6(allowIpv6) - , ACacheHits(0) - , ACacheMisses(0) - , PtrCacheHits(0) - , PtrCacheMisses(0) + : EntryLifetime(lifetime) + , NegativeLifetime(neg) + , Timeout(TDuration::MicroSeconds(timeout)) + , AllowIpV4(allowIpv4) + , AllowIpV6(allowIpv6) + , ACacheHits(0) + , ACacheMisses(0) + , PtrCacheHits(0) + , PtrCacheMisses(0) { #ifdef _win_ if (ares_library_init(ARES_LIB_INIT_WIN32) != ARES_SUCCESS) { @@ -40,7 +40,7 @@ TDnsCache::TDnsCache(bool allowIpv4, bool allowIpv6, time_t lifetime, time_t neg LWPROBE(Created); } -TDnsCache::~TDnsCache(void) { +TDnsCache::~TDnsCache(void) { ares_channel chan = static_cast<ares_channel>(Channel); ares_cancel(chan); @@ -52,29 +52,29 @@ TDnsCache::~TDnsCache(void) { #endif } -TString TDnsCache::GetHostByAddr(const NAddr::IRemoteAddr& addr) { +TString TDnsCache::GetHostByAddr(const NAddr::IRemoteAddr& addr) { in6_addr key; if (addr.Addr()->sa_family == AF_INET6) { - const struct sockaddr_in6* s6 = (const struct sockaddr_in6*)(addr.Addr()); + const struct sockaddr_in6* s6 = (const struct sockaddr_in6*)(addr.Addr()); memcpy(&key, &s6->sin6_addr, sizeof(s6->sin6_addr)); } else if (addr.Addr()->sa_family == AF_INET) { - const struct sockaddr_in* s4 = (const struct sockaddr_in*)(addr.Addr()); + const struct sockaddr_in* s4 = (const struct sockaddr_in*)(addr.Addr()); memset(&key, 0, sizeof(key)); memcpy(&key, &s4->sin_addr, sizeof(s4->sin_addr)); } else { return ""; } - const TAddr& host = ResolveAddr(key, addr.Addr()->sa_family); + const TAddr& host = ResolveAddr(key, addr.Addr()->sa_family); return host.Hostname; } -TIpHost TDnsCache::Get(const TString& hostname) { +TIpHost TDnsCache::Get(const TString& hostname) { if (!AllowIpV4) return TIpHost(-1); - const THost& addr = Resolve(hostname, AF_INET); + const THost& addr = Resolve(hostname, AF_INET); TGuard<TMutex> lock(CacheMtx); if (addr.AddrsV4.empty()) { @@ -84,12 +84,12 @@ TIpHost TDnsCache::Get(const TString& hostname) { } NAddr::IRemoteAddrPtr TDnsCache::GetAddr( - const TString& hostname, - int family, - TIpPort port, - bool cacheOnly) { + const TString& hostname, + int family, + TIpPort port, + bool cacheOnly) { if (family != AF_INET && AllowIpV6) { - const THost& addr = Resolve(hostname, AF_INET6, cacheOnly); + const THost& addr = Resolve(hostname, AF_INET6, cacheOnly); TGuard<TMutex> lock(CacheMtx); if (!addr.AddrsV6.empty()) { @@ -104,7 +104,7 @@ NAddr::IRemoteAddrPtr TDnsCache::GetAddr( } if (family != AF_INET6 && AllowIpV4) { - const THost& addr = Resolve(hostname, AF_INET, cacheOnly); + const THost& addr = Resolve(hostname, AF_INET, cacheOnly); TGuard<TMutex> lock(CacheMtx); if (!addr.AddrsV4.empty()) { @@ -117,10 +117,10 @@ NAddr::IRemoteAddrPtr TDnsCache::GetAddr( } void TDnsCache::GetAllAddresses( - const TString& hostname, - TVector<NAddr::IRemoteAddrPtr>& addrs) { + const TString& hostname, + TVector<NAddr::IRemoteAddrPtr>& addrs) { if (AllowIpV4) { - const THost& addr4 = Resolve(hostname, AF_INET); + const THost& addr4 = Resolve(hostname, AF_INET); TGuard<TMutex> lock(CacheMtx); for (size_t i = 0; i < addr4.AddrsV4.size(); i++) { @@ -129,7 +129,7 @@ void TDnsCache::GetAllAddresses( } if (AllowIpV6) { - const THost& addr6 = Resolve(hostname, AF_INET6); + const THost& addr6 = Resolve(hostname, AF_INET6); struct sockaddr_in6 sin6; Zero(sin6); @@ -144,8 +144,8 @@ void TDnsCache::GetAllAddresses( } } -void TDnsCache::GetStats(ui64& a_cache_hits, ui64& a_cache_misses, - ui64& ptr_cache_hits, ui64& ptr_cache_misses) { +void TDnsCache::GetStats(ui64& a_cache_hits, ui64& a_cache_misses, + ui64& ptr_cache_hits, ui64& ptr_cache_misses) { TGuard<TMutex> lock(CacheMtx); a_cache_hits = ACacheHits; @@ -154,7 +154,7 @@ void TDnsCache::GetStats(ui64& a_cache_hits, ui64& a_cache_misses, ptr_cache_misses = PtrCacheMisses; } -bool TDnsCache::THost::IsStale(int family, const TDnsCache* ctx) const noexcept { +bool TDnsCache::THost::IsStale(int family, const TDnsCache* ctx) const noexcept { time_t resolved = family == AF_INET ? ResolvedV4 : ResolvedV6; time_t notfound = family == AF_INET ? NotFoundV4 : NotFoundV6; @@ -168,7 +168,7 @@ bool TDnsCache::THost::IsStale(int family, const TDnsCache* ctx) const noexcept } const TDnsCache::THost& -TDnsCache::Resolve(const TString& hostname, int family, bool cacheOnly) { +TDnsCache::Resolve(const TString& hostname, int family, bool cacheOnly) { if (!ValidateHName(hostname)) { LWPROBE(ResolveNullHost, hostname, family); return NullHost; @@ -202,7 +202,7 @@ TDnsCache::Resolve(const TString& hostname, int family, bool cacheOnly) { if (cacheOnly) return NullHost; - TAtomic& inprogress = (family == AF_INET ? p->second.InProgressV4 : p->second.InProgressV6); + TAtomic& inprogress = (family == AF_INET ? p->second.InProgressV4 : p->second.InProgressV6); { /* This way only! CacheMtx should always be taken AFTER AresMtx, @@ -212,16 +212,16 @@ TDnsCache::Resolve(const TString& hostname, int family, bool cacheOnly) { TGuard<TMutex> areslock(AresMtx); TGuard<TMutex> cachelock(CacheMtx); - if (!inprogress) { + if (!inprogress) { ares_channel chan = static_cast<ares_channel>(Channel); - TGHBNContext* ctx = new TGHBNContext(); + TGHBNContext* ctx = new TGHBNContext(); ctx->Owner = this; ctx->Hostname = hostname; ctx->Family = family; AtomicSet(inprogress, 1); ares_gethostbyname(chan, hostname.c_str(), family, - &TDnsCache::GHBNCallback, ctx); + &TDnsCache::GHBNCallback, ctx); } } @@ -231,18 +231,18 @@ TDnsCache::Resolve(const TString& hostname, int family, bool cacheOnly) { return p->second; } -bool TDnsCache::ValidateHName(const TString& name) const noexcept { +bool TDnsCache::ValidateHName(const TString& name) const noexcept { return name.size() > 0; } -const TDnsCache::TAddr& TDnsCache::ResolveAddr(const in6_addr& addr, int family) { +const TDnsCache::TAddr& TDnsCache::ResolveAddr(const in6_addr& addr, int family) { TAddrCache::iterator p; { TGuard<TMutex> lock(CacheMtx); p = AddrCache.find(addr); if (p != AddrCache.end()) { - if (TTimeKeeper::GetTime() - p->second.Resolved < EntryLifetime || TTimeKeeper::GetTime() - p->second.NotFound < NegativeLifetime) { + if (TTimeKeeper::GetTime() - p->second.Resolved < EntryLifetime || TTimeKeeper::GetTime() - p->second.NotFound < NegativeLifetime) { /* Recently resolved, just return cached value */ PtrCacheHits += 1; return p->second; @@ -263,16 +263,16 @@ const TDnsCache::TAddr& TDnsCache::ResolveAddr(const in6_addr& addr, int family) TGuard<TMutex> areslock(AresMtx); TGuard<TMutex> cachelock(CacheMtx); - if (!p->second.InProgress) { + if (!p->second.InProgress) { ares_channel chan = static_cast<ares_channel>(Channel); - TGHBAContext* ctx = new TGHBAContext(); + TGHBAContext* ctx = new TGHBAContext(); ctx->Owner = this; ctx->Addr = addr; AtomicSet(p->second.InProgress, 1); ares_gethostbyaddr(chan, &addr, - family == AF_INET ? sizeof(in_addr) : sizeof(in6_addr), - family, &TDnsCache::GHBACallback, ctx); + family == AF_INET ? sizeof(in_addr) : sizeof(in6_addr), + family, &TDnsCache::GHBACallback, ctx); } } @@ -281,7 +281,7 @@ const TDnsCache::TAddr& TDnsCache::ResolveAddr(const in6_addr& addr, int family) return p->second; } -void TDnsCache::WaitTask(TAtomic& flag) { +void TDnsCache::WaitTask(TAtomic& flag) { const TInstant start = TInstant(TTimeKeeper::GetTimeval()); while (AtomicGet(flag)) { @@ -306,11 +306,11 @@ void TDnsCache::WaitTask(TAtomic& flag) { pfd[nfds].revents = 0; if (ARES_GETSOCK_READABLE(bits, nfds)) { pfd[nfds].fd = socks[nfds]; - pfd[nfds].events |= POLLRDNORM | POLLIN; + pfd[nfds].events |= POLLRDNORM | POLLIN; } if (ARES_GETSOCK_WRITABLE(bits, nfds)) { pfd[nfds].fd = socks[nfds]; - pfd[nfds].events |= POLLWRNORM | POLLOUT; + pfd[nfds].events |= POLLWRNORM | POLLOUT; } if (pfd[nfds].events == 0) { break; @@ -343,12 +343,12 @@ void TDnsCache::WaitTask(TAtomic& flag) { } TGuard<TMutex> lock(AresMtx); ares_process_fd(chan, - pfd[i].revents & (POLLRDNORM | POLLIN) - ? pfd[i].fd - : ARES_SOCKET_BAD, - pfd[i].revents & (POLLWRNORM | POLLOUT) - ? pfd[i].fd - : ARES_SOCKET_BAD); + pfd[i].revents & (POLLRDNORM | POLLIN) + ? pfd[i].fd + : ARES_SOCKET_BAD, + pfd[i].revents & (POLLWRNORM | POLLOUT) + ? pfd[i].fd + : ARES_SOCKET_BAD); } } @@ -358,22 +358,22 @@ void TDnsCache::WaitTask(TAtomic& flag) { } } -void TDnsCache::GHBNCallback(void* arg, int status, int, struct hostent* info) { - THolder<TGHBNContext> ctx(static_cast<TGHBNContext*>(arg)); +void TDnsCache::GHBNCallback(void* arg, int status, int, struct hostent* info) { + THolder<TGHBNContext> ctx(static_cast<TGHBNContext*>(arg)); TGuard<TMutex> lock(ctx->Owner->CacheMtx); THostCache::iterator p = ctx->Owner->HostCache.find(ctx->Hostname); Y_ASSERT(p != ctx->Owner->HostCache.end()); - time_t& resolved = (ctx->Family == AF_INET ? p->second.ResolvedV4 : p->second.ResolvedV6); - time_t& notfound = (ctx->Family == AF_INET ? p->second.NotFoundV4 : p->second.NotFoundV6); - TAtomic& inprogress = (ctx->Family == AF_INET ? p->second.InProgressV4 : p->second.InProgressV6); + time_t& resolved = (ctx->Family == AF_INET ? p->second.ResolvedV4 : p->second.ResolvedV6); + time_t& notfound = (ctx->Family == AF_INET ? p->second.NotFoundV4 : p->second.NotFoundV6); + TAtomic& inprogress = (ctx->Family == AF_INET ? p->second.InProgressV4 : p->second.InProgressV6); if (status == ARES_SUCCESS) { if (info->h_addrtype == AF_INET) { p->second.AddrsV4.clear(); for (int i = 0; info->h_addr_list[i] != nullptr; i++) { - p->second.AddrsV4.push_back(*(TIpHost*)(info->h_addr_list[i])); + p->second.AddrsV4.push_back(*(TIpHost*)(info->h_addr_list[i])); } /* It is possible to ask ares for IPv6 and have IPv4 addrs instead, so take care and set V4 timers anyway. @@ -384,7 +384,7 @@ void TDnsCache::GHBNCallback(void* arg, int status, int, struct hostent* info) { } else if (info->h_addrtype == AF_INET6) { p->second.AddrsV6.clear(); for (int i = 0; info->h_addr_list[i] != nullptr; i++) { - p->second.AddrsV6.push_back(*(struct in6_addr*)(info->h_addr_list[i])); + p->second.AddrsV6.push_back(*(struct in6_addr*)(info->h_addr_list[i])); } } else { Y_FAIL("unknown address type in ares callback"); @@ -398,8 +398,8 @@ void TDnsCache::GHBNCallback(void* arg, int status, int, struct hostent* info) { AtomicSet(inprogress, 0); } -void TDnsCache::GHBACallback(void* arg, int status, int, struct hostent* info) { - THolder<TGHBAContext> ctx(static_cast<TGHBAContext*>(arg)); +void TDnsCache::GHBACallback(void* arg, int status, int, struct hostent* info) { + THolder<TGHBAContext> ctx(static_cast<TGHBAContext*>(arg)); TGuard<TMutex> lock(ctx->Owner->CacheMtx); TAddrCache::iterator p = ctx->Owner->AddrCache.find(ctx->Addr); @@ -416,17 +416,17 @@ void TDnsCache::GHBACallback(void* arg, int status, int, struct hostent* info) { AtomicSet(p->second.InProgress, 0); } -TString TDnsCache::THost::AddrsV4ToString() const { +TString TDnsCache::THost::AddrsV4ToString() const { TStringStream ss; bool first = false; for (TIpHost addr : AddrsV4) { - ss << (first ? "" : " ") << IpToString(addr); + ss << (first ? "" : " ") << IpToString(addr); first = false; } return ss.Str(); } -TString TDnsCache::THost::AddrsV6ToString() const { +TString TDnsCache::THost::AddrsV6ToString() const { TStringStream ss; bool first = false; for (in6_addr addr : AddrsV6) { @@ -436,7 +436,7 @@ TString TDnsCache::THost::AddrsV6ToString() const { sin6.sin6_addr = addr; NAddr::TIPv6Addr addr6(sin6); - ss << (first ? "" : " ") << NAddr::PrintHost(addr6); + ss << (first ? "" : " ") << NAddr::PrintHost(addr6); first = false; } return ss.Str(); diff --git a/library/cpp/actors/dnscachelib/dnscache.h b/library/cpp/actors/dnscachelib/dnscache.h index a8e80de628..3313a251a1 100644 --- a/library/cpp/actors/dnscachelib/dnscache.h +++ b/library/cpp/actors/dnscachelib/dnscache.h @@ -24,47 +24,47 @@ public: TString GetHostByAddr(const NAddr::IRemoteAddr&); // ip in network byte order - TIpHost Get(const TString& host); + TIpHost Get(const TString& host); /* use with AF_INET, AF_INET6 or AF_UNSPEC */ - NAddr::IRemoteAddrPtr GetAddr(const TString& host, + NAddr::IRemoteAddrPtr GetAddr(const TString& host, int family, TIpPort port = 0, bool cacheOnly = false); - void GetAllAddresses(const TString& host, TVector<NAddr::IRemoteAddrPtr>&); + void GetAllAddresses(const TString& host, TVector<NAddr::IRemoteAddrPtr>&); - void GetStats(ui64& a_cache_hits, ui64& a_cache_misses, - ui64& ptr_cache_hits, ui64& ptr_cache_misses); + void GetStats(ui64& a_cache_hits, ui64& a_cache_misses, + ui64& ptr_cache_hits, ui64& ptr_cache_misses); protected: - bool ValidateHName(const TString& host) const noexcept; + bool ValidateHName(const TString& host) const noexcept; private: struct TGHBNContext { - TDnsCache* Owner; + TDnsCache* Owner; TString Hostname; int Family; }; struct TGHBAContext { - TDnsCache* Owner; + TDnsCache* Owner; in6_addr Addr; }; struct THost { - THost() noexcept { - } + THost() noexcept { + } TVector<TIpHost> AddrsV4; - time_t ResolvedV4 = 0; - time_t NotFoundV4 = 0; - TAtomic InProgressV4 = 0; + time_t ResolvedV4 = 0; + time_t NotFoundV4 = 0; + TAtomic InProgressV4 = 0; TVector<in6_addr> AddrsV6; - time_t ResolvedV6 = 0; - time_t NotFoundV6 = 0; - TAtomic InProgressV6 = 0; + time_t ResolvedV6 = 0; + time_t NotFoundV6 = 0; + TAtomic InProgressV6 = 0; TString AddrsV4ToString() const; TString AddrsV6ToString() const; @@ -75,16 +75,16 @@ private: typedef TMap<TString, THost> THostCache; struct TAddr { - TString Hostname; - time_t Resolved = 0; - time_t NotFound = 0; - TAtomic InProgress = 0; + TString Hostname; + time_t Resolved = 0; + time_t NotFound = 0; + TAtomic InProgress = 0; }; /* IRemoteAddr is annoingly hard to use, so I'll use in6_addr as key * and put v4 addrs in it. */ struct TAddrCmp { - bool operator()(const in6_addr& left, const in6_addr& right) const { + bool operator()(const in6_addr& left, const in6_addr& right) const { for (size_t i = 0; i < sizeof(left); i++) { if (left.s6_addr[i] < right.s6_addr[i]) { return true; @@ -98,17 +98,17 @@ private: }; typedef TMap<in6_addr, TAddr, TAddrCmp> TAddrCache; - const THost& Resolve(const TString&, int family, bool cacheOnly = false); + const THost& Resolve(const TString&, int family, bool cacheOnly = false); - const TAddr& ResolveAddr(const in6_addr&, int family); + const TAddr& ResolveAddr(const in6_addr&, int family); - void WaitTask(TAtomic&); + void WaitTask(TAtomic&); - static void GHBNCallback(void* arg, int status, int timeouts, - struct hostent* info); + static void GHBNCallback(void* arg, int status, int timeouts, + struct hostent* info); - static void GHBACallback(void* arg, int status, int timeouts, - struct hostent* info); + static void GHBACallback(void* arg, int status, int timeouts, + struct hostent* info); const time_t EntryLifetime; const time_t NegativeLifetime; @@ -127,7 +127,7 @@ private: const static THost NullHost; TMutex AresMtx; - void* Channel; + void* Channel; struct TAresLibInit { TAresLibInit() { diff --git a/library/cpp/actors/dnscachelib/probes.h b/library/cpp/actors/dnscachelib/probes.h index 9e4781817f..313b7b8712 100644 --- a/library/cpp/actors/dnscachelib/probes.h +++ b/library/cpp/actors/dnscachelib/probes.h @@ -2,34 +2,34 @@ #include <library/cpp/lwtrace/all.h> -#define DNSCACHELIB_PROVIDER(PROBE, EVENT, GROUPS, TYPES, NAMES) \ - PROBE(Created, GROUPS(), TYPES(), NAMES()) \ - PROBE(Destroyed, GROUPS(), TYPES(), NAMES()) \ - PROBE(AresInitFailed, GROUPS(), TYPES(), NAMES()) \ - PROBE(FamilyMismatch, \ - GROUPS(), \ - TYPES(int, bool, bool), \ - NAMES("family", "allowIpV4", "allowIpV6")) \ - PROBE(ResolveNullHost, \ - GROUPS(), \ - TYPES(TString, int), \ - NAMES("hostname", "family")) \ - PROBE(ResolveFromCache, \ - GROUPS(), \ - TYPES(TString, int, TString, TString, ui64), \ - NAMES("hostname", "family", "addrsV4", "addrsV6", "aCacheHits")) \ - PROBE(ResolveDone, \ - GROUPS(), \ - TYPES(TString, int, TString, TString), \ - NAMES("hostname", "family", "addrsV4", "addrsV6")) \ - PROBE(ResolveCacheTimeout, \ - GROUPS(), \ - TYPES(TString), \ - NAMES("hostname")) \ - PROBE(ResolveCacheNew, \ - GROUPS(), \ - TYPES(TString), \ - NAMES("hostname")) \ +#define DNSCACHELIB_PROVIDER(PROBE, EVENT, GROUPS, TYPES, NAMES) \ + PROBE(Created, GROUPS(), TYPES(), NAMES()) \ + PROBE(Destroyed, GROUPS(), TYPES(), NAMES()) \ + PROBE(AresInitFailed, GROUPS(), TYPES(), NAMES()) \ + PROBE(FamilyMismatch, \ + GROUPS(), \ + TYPES(int, bool, bool), \ + NAMES("family", "allowIpV4", "allowIpV6")) \ + PROBE(ResolveNullHost, \ + GROUPS(), \ + TYPES(TString, int), \ + NAMES("hostname", "family")) \ + PROBE(ResolveFromCache, \ + GROUPS(), \ + TYPES(TString, int, TString, TString, ui64), \ + NAMES("hostname", "family", "addrsV4", "addrsV6", "aCacheHits")) \ + PROBE(ResolveDone, \ + GROUPS(), \ + TYPES(TString, int, TString, TString), \ + NAMES("hostname", "family", "addrsV4", "addrsV6")) \ + PROBE(ResolveCacheTimeout, \ + GROUPS(), \ + TYPES(TString), \ + NAMES("hostname")) \ + PROBE(ResolveCacheNew, \ + GROUPS(), \ + TYPES(TString), \ + NAMES("hostname")) \ /**/ LWTRACE_DECLARE_PROVIDER(DNSCACHELIB_PROVIDER) diff --git a/library/cpp/actors/dnscachelib/timekeeper.h b/library/cpp/actors/dnscachelib/timekeeper.h index daf62ebeaa..0528d8549c 100644 --- a/library/cpp/actors/dnscachelib/timekeeper.h +++ b/library/cpp/actors/dnscachelib/timekeeper.h @@ -21,17 +21,17 @@ public: return Singleton<TTimeKeeper>()->CurrentTime.tv_sec; } - static const struct timeval& GetTimeval(void) { + static const struct timeval& GetTimeval(void) { return Singleton<TTimeKeeper>()->CurrentTime; } TTimeKeeper() - : Thread(&TTimeKeeper::Worker, this) + : Thread(&TTimeKeeper::Worker, this) { ConstTime = !!GetEnv("TEST_TIME"); if (ConstTime) { try { - CurrentTime.tv_sec = FromString<ui32>(GetEnv("TEST_TIME")); + CurrentTime.tv_sec = FromString<ui32>(GetEnv("TEST_TIME")); } catch (TFromStringException exc) { ConstTime = false; } @@ -56,8 +56,8 @@ private: TSystemEvent Exit; TThread Thread; - static void* Worker(void* arg) { - TTimeKeeper* owner = static_cast<TTimeKeeper*>(arg); + static void* Worker(void* arg) { + TTimeKeeper* owner = static_cast<TTimeKeeper*>(arg); do { /* Race condition may occur here but locking looks too expensive */ |